Sat, 03 Dec 2022 16:31:08 +0100
use separate buffer for chunked transfer encoding, not inbuf
src/server/daemon/httprequest.c | file | annotate | diff | comparison | revisions |
--- a/src/server/daemon/httprequest.c Sat Dec 03 13:54:53 2022 +0100 +++ b/src/server/daemon/httprequest.c Sat Dec 03 16:31:08 2022 +0100 @@ -302,7 +302,6 @@ absPath.length, rq->rq.reqpb); } else { - // TODO: log error log_ereport( LOG_WARN, "uri unescape failed: {%.*s}", @@ -421,16 +420,28 @@ if(transfer_encoding) { if(!strcmp(transfer_encoding, "chunked")) { netbuf *nb = sn->netbuf; - sn->buffer = (char*)nb->inbuf; + sn->buffer = pool_malloc(pool, nb->maxsize); + if(!sn->buffer) { + pool_destroy(pool); + // TODO: error 500 + return 1; + } + if(nb->cursize - nb->pos > 0) { + memcpy(sn->buffer, nb->inbuf, nb->cursize); + } + sn->pos = nb->pos; sn->cursize = nb->cursize; + nb->pos = 0; + nb->cursize = 0; + if(httpstream_enable_chunked_read(sn->sn.csd, sn->buffer, nb->maxsize, &sn->cursize, &sn->pos)) { pool_destroy(pool); // TODO: error 500 return 1; } - } + } // else: TODO: unknown transfer encoding error } //