summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-12-15 16:53:04 +0100
committerDaniel Stenberg <daniel@haxx.se>2020-12-17 14:00:27 +0100
commita5bc272223681e1473f260ab9580b50753f25b7b (patch)
tree4ee76757e6e51c8fd4c19c7556fa45d6b3d68317 /lib
parent3e17c8ab72e66bdd2faef5561de5030c519e3359 (diff)
downloadcurl-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')
-rw-r--r--lib/http.c5
-rw-r--r--lib/transfer.c26
-rw-r--r--lib/urldata.h2
3 files changed, 28 insertions, 5 deletions
diff --git a/lib/http.c b/lib/http.c
index c232ed413..a2279eb0a 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -1294,6 +1294,9 @@ CURLcode Curl_buffer_send(struct dynbuf *in,
http->postdata = ptr;
http->postsize = (curl_off_t)size;
+ /* this much data is remaining header: */
+ data->req.pendingheader = headersize - headlen;
+
http->send_buffer = *in; /* copy the whole struct */
http->sending = HTTPSEND_REQUEST;
@@ -1316,6 +1319,8 @@ CURLcode Curl_buffer_send(struct dynbuf *in,
}
Curl_dyn_free(in);
+ /* no remaining header data */
+ data->req.pendingheader = 0;
return result;
}
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)) {
diff --git a/lib/urldata.h b/lib/urldata.h
index 4679c9d46..296341ebd 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -604,6 +604,8 @@ struct SingleRequest {
following second response code) result in a
CURLE_GOT_NOTHING error code */
+ curl_off_t pendingheader; /* this many bytes left to send is actually
+ header and not body */
struct curltime start; /* transfer started at this time */
struct curltime now; /* current time */
enum {