]> granicus.if.org Git - curl/commitdiff
Chunked-transfers should have an additional CRLF after the final 0 CRLF
authorDaniel Stenberg <daniel@haxx.se>
Wed, 28 Jan 2004 17:07:22 +0000 (17:07 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 28 Jan 2004 17:07:22 +0000 (17:07 +0000)
sequence.

lib/http.c
lib/transfer.c
tests/data/test56

index 0dcaf78664c202412cc501753140fe67c4732dc2..c3862cdedb61af491c8bb567cc6203119dd9c63e 100644 (file)
@@ -1614,8 +1614,8 @@ CURLcode Curl_http(struct connectdata *conn)
             /* Append the POST data chunky-style */
             add_bufferf(req_buffer, "%x\r\n", postsize);
             add_buffer(req_buffer, data->set.postfields, postsize);
-            add_buffer(req_buffer, "\r\n0\r\n", 5); /* end of a chunked
-                                                       transfer stream */
+            add_buffer(req_buffer, "\r\n0\r\n\r\n", 7); /* end of a chunked
+                                                           transfer stream */
           }
         }
         else {
index 3c2bf4baf21a6c762d482bc9d238cf821342c82b..eb0c99452db8a75adb8fa5236d7476ecd6d605ee 100644 (file)
@@ -152,16 +152,16 @@ static int fillbuffer(struct connectdata *conn,
 
     /* copy the prefix to the buffer */
     memcpy(conn->upload_fromhere, hexbuffer, hexlen);
-    if(nread>hexlen) {
-      /* append CRLF to the data */
-      memcpy(conn->upload_fromhere +
-             nread, "\r\n", 2);
-      nread+=2;
-    }
-    else {
+
+    /* always append CRLF to the data */
+    memcpy(conn->upload_fromhere + nread, "\r\n", 2);
+
+    if((nread - hexlen) == 0) {
       /* mark this as done once this chunk is transfered */
       conn->keep.upload_done = TRUE;
     }
+
+    nread+=2; /* for the added CRLF */
   }
   return nread;
 }
index 78e29f62e104097264015210f98b5fa271bed685..fa0a6e4d14174aa016cc75484b10e51d709b1743 100644 (file)
@@ -48,5 +48,6 @@ Content-Type: application/x-www-form-urlencoded
 c\r
 we post this\r
 0\r
+\r
 </protocol>
 </verify>