]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
http: don't consider upload done if the request isn't completely sent off
authorDaniel Stenberg <daniel@haxx.se>
Tue, 7 Apr 2020 16:16:01 +0000 (18:16 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 8 Apr 2020 06:14:23 +0000 (08:14 +0200)
Fixes #4919
Closes #5197

lib/http.c
lib/transfer.c

index e53f0d4824e1cbaa2f7f872e8f4f9d986d7c07b2..5a2edf09ee1cbb1083515f0e926397e463957124 100644 (file)
@@ -3057,7 +3057,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
   }
   if(result)
     return result;
-  if(!postsize)
+  if(!postsize && (http->sending != HTTPSEND_REQUEST))
     data->req.upload_done = TRUE;
 
   if(data->req.writebytecount) {
index 27c984f8f89721afeaeba7e3480891c16792a44d..d5eb2c3274ac30962303afa92e489e7280db8f59 100644 (file)
@@ -1837,15 +1837,21 @@ Curl_setup_transfer(
 {
   struct SingleRequest *k = &data->req;
   struct connectdata *conn = data->conn;
+  struct HTTP *http = data->req.protop;
+  bool httpsending = ((conn->handler->protocol&PROTO_FAMILY_HTTP) &&
+                      (http->sending == HTTPSEND_REQUEST));
   DEBUGASSERT(conn != NULL);
   DEBUGASSERT((sockindex <= 1) && (sockindex >= -1));
 
-  if(conn->bits.multiplex || conn->httpversion == 20) {
+  if(conn->bits.multiplex || conn->httpversion == 20 || httpsending) {
     /* when multiplexing, the read/write sockets need to be the same! */
     conn->sockfd = sockindex == -1 ?
       ((writesockindex == -1 ? CURL_SOCKET_BAD : conn->sock[writesockindex])) :
       conn->sock[sockindex];
     conn->writesockfd = conn->sockfd;
+    if(httpsending)
+      /* special and very HTTP-specific */
+      writesockindex = FIRSTSOCKET;
   }
   else {
     conn->sockfd = sockindex == -1 ?
@@ -1873,7 +1879,6 @@ Curl_setup_transfer(
       k->keepon |= KEEP_RECV;
 
     if(writesockindex != -1) {
-      struct HTTP *http = data->req.protop;
       /* HTTP 1.1 magic:
 
          Even if we require a 100-return code before uploading data, we might