src/server/daemon/httprequest.c

changeset 449
a28a5ccc894b
parent 448
02b003f7560c
child 460
b9a447b02046
--- a/src/server/daemon/httprequest.c	Sat Dec 03 16:31:08 2022 +0100
+++ b/src/server/daemon/httprequest.c	Sat Dec 03 18:00:35 2022 +0100
@@ -420,12 +420,15 @@
     if(transfer_encoding) {
         if(!strcmp(transfer_encoding, "chunked")) {
             netbuf *nb = sn->netbuf;
+            // a separate buffer is required for reading chunked transfer enc
             sn->buffer = pool_malloc(pool, nb->maxsize);
             if(!sn->buffer) {
                 pool_destroy(pool);
                 // TODO: error 500 
                 return 1;
             }
+            
+            // copy remaining bytes from inbuf to the additional buffer
             if(nb->cursize - nb->pos > 0) {
                 memcpy(sn->buffer, nb->inbuf, nb->cursize);
             }
@@ -433,6 +436,7 @@
             sn->pos = nb->pos;
             sn->cursize = nb->cursize;
             
+            // clear inbuf
             nb->pos = 0;
             nb->cursize = 0;
             

mercurial