|
|
@ -223,12 +223,16 @@ void httpdQueueHeader(HttpdConnData *conn, const char *header, const char *value |
|
|
|
strcat(queEntry->headerLine, value); |
|
|
|
strcat(queEntry->headerLine, value); |
|
|
|
strcat(queEntry->headerLine, "\r\n"); |
|
|
|
strcat(queEntry->headerLine, "\r\n"); |
|
|
|
|
|
|
|
|
|
|
|
// Attach it to the linked list
|
|
|
|
if (!conn->priv->headersToSend) { |
|
|
|
HttpdQueuedHeader **ph = &conn->priv->headersToSend; |
|
|
|
conn->priv->headersToSend = queEntry; |
|
|
|
while (*ph) { |
|
|
|
} else { |
|
|
|
ph = &(*ph)->next; |
|
|
|
HttpdQueuedHeader *ph = conn->priv->headersToSend; |
|
|
|
|
|
|
|
// Go to the end of the linked list
|
|
|
|
|
|
|
|
while (ph->next) { |
|
|
|
|
|
|
|
ph = ph->next; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ph->next = queEntry; |
|
|
|
} |
|
|
|
} |
|
|
|
*ph = queEntry; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void httdSetTransferMode(HttpdConnData *conn, httpd_transfer_opt mode) |
|
|
|
void httdSetTransferMode(HttpdConnData *conn, httpd_transfer_opt mode) |
|
|
@ -292,8 +296,9 @@ void httpdHeader(HttpdConnData *conn, const char *field, const char *val) |
|
|
|
//Finish the headers.
|
|
|
|
//Finish the headers.
|
|
|
|
void httpdEndHeaders(HttpdConnData *conn) |
|
|
|
void httpdEndHeaders(HttpdConnData *conn) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Add queued headers
|
|
|
|
// Add queued headers & dealloc the struct
|
|
|
|
HttpdQueuedHeader *qh = conn->priv->headersToSend; |
|
|
|
HttpdQueuedHeader *qh = conn->priv->headersToSend; |
|
|
|
|
|
|
|
conn->priv->headersToSend = NULL; |
|
|
|
while (qh) { |
|
|
|
while (qh) { |
|
|
|
httpdSendStr(conn, qh->headerLine); |
|
|
|
httpdSendStr(conn, qh->headerLine); |
|
|
|
HttpdQueuedHeader *next = qh->next; |
|
|
|
HttpdQueuedHeader *next = qh->next; |
|
|
@ -473,7 +478,7 @@ bool httpdFlushSendBuffer(HttpdConnData *conn) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void httpdCgiIsDone(HttpdConnData *conn) |
|
|
|
static void httpdCgiIsDone(HttpdConnData *conn) |
|
|
|
{ |
|
|
|
{ |
|
|
|
conn->cgi = NULL; //no need to call this anymore
|
|
|
|
conn->cgi = NULL; //no need to call this anymore
|
|
|
|
if (conn->priv->flags & HFL_CHUNKED) { |
|
|
|
if (conn->priv->flags & HFL_CHUNKED) { |
|
|
@ -723,7 +728,7 @@ static void httpdParseHeader(char *h, HttpdConnData *conn) |
|
|
|
http_dbg("Mallocced buffer for %d + 1 bytes of post data.", (int) conn->post->buffSize); |
|
|
|
http_dbg("Mallocced buffer for %d + 1 bytes of post data.", (int) conn->post->buffSize); |
|
|
|
conn->post->buff = (char *) httpdPlatMalloc(conn->post->buffSize + 1); |
|
|
|
conn->post->buff = (char *) httpdPlatMalloc(conn->post->buffSize + 1); |
|
|
|
if (conn->post->buff == NULL) { |
|
|
|
if (conn->post->buff == NULL) { |
|
|
|
http_error("...failed!"); |
|
|
|
http_error("post buf alloc failed"); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
conn->post->buffLen = 0; |
|
|
|
conn->post->buffLen = 0; |
|
|
@ -937,10 +942,15 @@ int httpdConnectCb(ConnTypePtr conn, const uint8_t *remIp, uint16_t remPort) |
|
|
|
} |
|
|
|
} |
|
|
|
memset(s_connData[i], 0, sizeof(HttpdConnData)); |
|
|
|
memset(s_connData[i], 0, sizeof(HttpdConnData)); |
|
|
|
s_connData[i]->priv = httpdPlatMalloc(sizeof(HttpdPriv)); |
|
|
|
s_connData[i]->priv = httpdPlatMalloc(sizeof(HttpdPriv)); |
|
|
|
|
|
|
|
if (s_connData[i]->priv == NULL) { |
|
|
|
|
|
|
|
http_error("Out of memory allocating connData priv struct!"); |
|
|
|
|
|
|
|
httpdPlatUnlock(); |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
memset(s_connData[i]->priv, 0, sizeof(HttpdPriv)); |
|
|
|
memset(s_connData[i]->priv, 0, sizeof(HttpdPriv)); |
|
|
|
s_connData[i]->conn = conn; |
|
|
|
s_connData[i]->conn = conn; |
|
|
|
s_connData[i]->slot = i; |
|
|
|
s_connData[i]->slot = i; |
|
|
|
s_connData[i]->priv->headPos = 0; |
|
|
|
// s_connData[i]->priv->headPos = 0;
|
|
|
|
s_connData[i]->post = httpdPlatMalloc(sizeof(HttpdPostData)); |
|
|
|
s_connData[i]->post = httpdPlatMalloc(sizeof(HttpdPostData)); |
|
|
|
if (s_connData[i]->post == NULL) { |
|
|
|
if (s_connData[i]->post == NULL) { |
|
|
|
http_error("Out of memory allocating connData post struct!"); |
|
|
|
http_error("Out of memory allocating connData post struct!"); |
|
|
@ -948,14 +958,15 @@ int httpdConnectCb(ConnTypePtr conn, const uint8_t *remIp, uint16_t remPort) |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
memset(s_connData[i]->post, 0, sizeof(HttpdPostData)); |
|
|
|
memset(s_connData[i]->post, 0, sizeof(HttpdPostData)); |
|
|
|
s_connData[i]->post->buff = NULL; |
|
|
|
// s_connData[i]->post->buff = NULL;
|
|
|
|
s_connData[i]->post->buffLen = 0; |
|
|
|
// s_connData[i]->post->buffLen = 0;
|
|
|
|
s_connData[i]->post->received = 0; |
|
|
|
// s_connData[i]->post->received = 0;
|
|
|
|
s_connData[i]->post->len = -1; |
|
|
|
s_connData[i]->post->len = -1; |
|
|
|
s_connData[i]->hostName = NULL; |
|
|
|
// s_connData[i]->hostName = NULL;
|
|
|
|
s_connData[i]->remote_port = remPort; |
|
|
|
s_connData[i]->remote_port = remPort; |
|
|
|
s_connData[i]->priv->sendBacklog = NULL; |
|
|
|
// s_connData[i]->priv->sendBacklog = NULL;
|
|
|
|
s_connData[i]->priv->sendBacklogSize = 0; |
|
|
|
// s_connData[i]->priv->headersToSend = NULL;
|
|
|
|
|
|
|
|
// s_connData[i]->priv->sendBacklogSize = 0;
|
|
|
|
memcpy(s_connData[i]->remote_ip, remIp, 4); |
|
|
|
memcpy(s_connData[i]->remote_ip, remIp, 4); |
|
|
|
|
|
|
|
|
|
|
|
httpdPlatUnlock(); |
|
|
|
httpdPlatUnlock(); |
|
|
|