Skip to content

Commit

Permalink
http: don't consider upload done if the request isn't completely sent…
Browse files Browse the repository at this point in the history
… off

Fixes #4919
  • Loading branch information
bagder committed Apr 7, 2020
1 parent 0f3310b commit 02d03c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 7 additions & 2 deletions lib/transfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 02d03c2

Please sign in to comment.