diff options
author | Daniel Stenberg <daniel@haxx.se> | 2020-12-15 16:53:04 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-12-17 14:00:27 +0100 |
commit | a5bc272223681e1473f260ab9580b50753f25b7b (patch) | |
tree | 4ee76757e6e51c8fd4c19c7556fa45d6b3d68317 /lib/transfer.c | |
parent | 3e17c8ab72e66bdd2faef5561de5030c519e3359 (diff) | |
download | curl-a5bc272223681e1473f260ab9580b50753f25b7b.tar.gz |
http: show the request as headers even when split-sending
When the initial request isn't possible to send in its entirety, the
remainder of request would be delivered to the debug callback as data
and would wrongly be counted internally as body-bytes sent.
Extended test 1295 to verify.
Closes #6328
Diffstat (limited to 'lib/transfer.c')
-rw-r--r-- | lib/transfer.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/transfer.c b/lib/transfer.c index bfd0218fe..8fcb71832 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -1016,6 +1016,8 @@ static CURLcode readwrite_upload(struct Curl_easy *data, *didwhat |= KEEP_SEND; do { + curl_off_t nbody; + /* only read more data if there's no upload data already present in the upload buffer */ if(0 == k->upload_present) { @@ -1153,12 +1155,26 @@ static CURLcode readwrite_upload(struct Curl_easy *data, win_update_buffer_size(conn->writesockfd); - /* show the data before we change the pointer upload_fromhere */ - Curl_debug(data, CURLINFO_DATA_OUT, k->upload_fromhere, - (size_t)bytes_written); + if(k->pendingheader) { + /* parts of what was sent was header */ + curl_off_t n = CURLMIN(k->pendingheader, bytes_written); + /* show the data before we change the pointer upload_fromhere */ + Curl_debug(data, CURLINFO_HEADER_OUT, k->upload_fromhere, (size_t)n); + k->pendingheader -= n; + nbody = bytes_written - n; /* size of the written body part */ + } + else + nbody = bytes_written; - k->writebytecount += bytes_written; - Curl_pgrsSetUploadCounter(data, k->writebytecount); + if(nbody) { + /* show the data before we change the pointer upload_fromhere */ + Curl_debug(data, CURLINFO_DATA_OUT, + &k->upload_fromhere[bytes_written - nbody], + (size_t)nbody); + + k->writebytecount += nbody; + Curl_pgrsSetUploadCounter(data, k->writebytecount); + } if((!k->upload_chunky || k->forbidchunk) && (k->writebytecount == data->state.infilesize)) { |