kore

An easy to use, scalable and secure web application framework for writing web APIs in C.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 21a44589fc9f5be38edcc80286d26108d0e31818
parent 0ebcbe4f185e0fc201f7d7179365549a1187af4e
Author: Joris Vink <joris@coders.se>
Date:   Wed, 10 Jul 2013 13:34:42 +0200

If we already have all the POST data in the netbuf do not try and read more.

Diffstat:
src/http.c | 18+++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/http.c b/src/http.c @@ -295,9 +295,9 @@ http_header_recv(struct netbuf *nb) struct http_header *hdr; struct http_request *req; struct netbuf *nnb; - int h, i, v, skip; + size_t clen, len; u_int8_t *end_headers, ch; - size_t clen, len, bytes_left; + int h, i, v, skip, bytes_left; char *request[4], *host[3], *hbuf; char *p, *headers[HTTP_REQ_HEADER_MAX]; struct connection *c = (struct connection *)nb->owner; @@ -417,9 +417,17 @@ http_header_recv(struct netbuf *nb) (nb->offset - len)); bytes_left = clen - (nb->offset - len); - kore_debug("need %ld more bytes for POST", bytes_left); - net_recv_queue(c, bytes_left, 0, &nnb, http_post_data_recv); - nnb->extra = req; + if (bytes_left > 0) { + kore_debug("need %ld more bytes for POST", bytes_left); + net_recv_queue(c, bytes_left, + 0, &nnb, http_post_data_recv); + nnb->extra = req; + } else if (bytes_left == 0) { + req->flags |= HTTP_REQUEST_COMPLETE; + } else { + kore_debug("bytes_left would become zero (%ld)", clen); + return (KORE_RESULT_ERROR); + } } return (KORE_RESULT_OK);