summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-10-30 11:29:22 +0100
committerDaniel Stenberg <daniel@haxx.se>2020-10-30 11:32:10 +0100
commit957127eac5ccbfb142a8def15cb79ce779a5996a (patch)
tree27e0243492ec1f4712fd1b98fc72730c19ec5b4a
parente4d38014cd74a43644774589eed00ce210022b3e (diff)
downloadcurl-bagder/debug-chunked-reqbody.tar.gz
http: pass correct header size to debug callback for chunked postbagder/debug-chunked-reqbody
... when the chunked framing was added, the size of the "body part" of the data was calculated wrongly so the debug callback would get told a header chunk a few bytes too big that would also contain the first few bytes of the request body. Reported-by: Dirk Wetter Ref: #6144
-rw-r--r--lib/http.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/http.c b/lib/http.c
index a5f42eb97..d775c0b39 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -2873,20 +2873,24 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
}
else {
if(postsize) {
+ char chunk[16];
/* Append the POST data chunky-style */
- result = Curl_dyn_addf(&req, "%x\r\n", (int)postsize);
+ msnprintf(chunk, sizeof(chunk), "%x\r\n", (int)postsize);
+ result = Curl_dyn_add(&req, chunk);
if(!result) {
+ included_body = postsize + strlen(chunk);
result = Curl_dyn_addn(&req, data->set.postfields,
(size_t)postsize);
if(!result)
result = Curl_dyn_add(&req, "\r\n");
- included_body = postsize + 2;
+ included_body += 2;
}
}
- if(!result)
+ if(!result) {
result = Curl_dyn_add(&req, "\x30\x0d\x0a\x0d\x0a");
- /* 0 CR LF CR LF */
- included_body += 5;
+ /* 0 CR LF CR LF */
+ included_body += 5;
+ }
}
if(result)
return result;