diff options
Diffstat (limited to 'lib/transfer.c')
-rw-r--r-- | lib/transfer.c | 64 |
1 files changed, 45 insertions, 19 deletions
diff --git a/lib/transfer.c b/lib/transfer.c index f316000a..065c7341 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -125,7 +125,7 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp) #ifdef CURL_DOES_CONVERSIONS bool sending_http_headers = FALSE; - if((conn->protocol&(PROT_HTTP|PROT_RTSP)) && + if((conn->handler->protocol&(CURLPROTO_HTTP|CURLPROTO_RTSP)) && (data->state.proto.http->sending == HTTPSEND_REQUEST)) { /* We're sending the HTTP request headers, not the data. Remember that so we don't re-translate them into garbage. */ @@ -322,7 +322,7 @@ static int data_pending(const struct connectdata *conn) { /* in the case of libssh2, we can never be really sure that we have emptied its internal buffers so we MUST always try until we get EAGAIN back */ - return conn->protocol&(PROT_SCP|PROT_SFTP) || + return conn->handler->protocol&(CURLPROTO_SCP|CURLPROTO_SFTP) || Curl_ssl_data_pending(conn, FIRSTSOCKET); } @@ -359,7 +359,7 @@ static void read_rewind(struct connectdata *conn, * Check to see if CURLOPT_TIMECONDITION was met by comparing the time of the * remote document with the time provided by CURLOPT_TIMEVAL */ -bool Curl_meets_timecondition(struct SessionHandle *data, long timeofdoc) +bool Curl_meets_timecondition(struct SessionHandle *data, time_t timeofdoc) { if((timeofdoc == 0) || (data->set.timevalue == 0)) return TRUE; @@ -469,7 +469,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, #ifndef CURL_DISABLE_RTSP /* Check for RTP at the beginning of the data */ - if(conn->protocol & PROT_RTSP) { + if(conn->handler->protocol & CURLPROTO_RTSP) { result = Curl_rtsp_rtp_readwrite(data, conn, &nread, &readmore); if(result) return result; @@ -490,7 +490,8 @@ static CURLcode readwrite_data(struct SessionHandle *data, #ifndef CURL_DISABLE_RTSP /* Check for RTP after the headers if there is no Content */ - if(k->maxdownload <= 0 && nread > 0 && (conn->protocol & PROT_RTSP)) { + if(k->maxdownload <= 0 && nread > 0 && + (conn->handler->protocol & CURLPROTO_RTSP)) { result = Curl_rtsp_rtp_readwrite(data, conn, &nread, &readmore); if(result) return result; @@ -499,9 +500,28 @@ static CURLcode readwrite_data(struct SessionHandle *data, } #endif - if(stop_reading) + if(stop_reading) { /* We've stopped dealing with input, get out of the do-while loop */ - break; + + if(nread > 0) { + if(conn->data->multi && Curl_multi_canPipeline(conn->data->multi)) { + infof(data, + "Rewinding stream by : %zd" + " bytes on url %s (zero-length body)\n", + nread, data->state.path); + read_rewind(conn, (size_t)nread); + } + else { + infof(data, + "Excess found in a non pipelined read:" + " excess = %zd" + " url = %s (zero-length body)\n", + nread, data->state.path); + } + } + + break; + } } #endif /* CURL_DISABLE_HTTP */ @@ -516,7 +536,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, if(0 == k->bodywrites && !is_empty_data) { /* These checks are only made the first time we are about to write a piece of the body */ - if(conn->protocol&(PROT_HTTP|PROT_RTSP)) { + if(conn->handler->protocol&(CURLPROTO_HTTP|CURLPROTO_RTSP)) { /* HTTP-only checks */ if(data->req.newurl) { @@ -703,7 +723,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, if(!k->ignorebody) { #ifndef CURL_DISABLE_POP3 - if(conn->protocol&PROT_POP3) + if(conn->handler->protocol&CURLPROTO_POP3) result = Curl_pop3_write(conn, k->str, nread); else #endif /* CURL_DISABLE_POP3 */ @@ -746,7 +766,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, #ifndef CURL_DISABLE_RTSP if(excess > 0 && !conn->bits.stream_was_rewound && - (conn->protocol & PROT_RTSP)) { + (conn->handler->protocol & CURLPROTO_RTSP)) { /* Check for RTP after the content if there is unrewound excess */ /* Parse the excess data */ @@ -834,7 +854,7 @@ static CURLcode readwrite_upload(struct SessionHandle *data, break; } - if(conn->protocol&(PROT_HTTP|PROT_RTSP)) { + if(conn->handler->protocol&(CURLPROTO_HTTP|CURLPROTO_RTSP)) { if(data->state.proto.http->sending == HTTPSEND_REQUEST) /* We're sending the HTTP request headers, not the data. Remember that so we don't change the line endings. */ @@ -872,7 +892,7 @@ static CURLcode readwrite_upload(struct SessionHandle *data, data->req.upload_present = nread; #ifndef CURL_DISABLE_SMTP - if(conn->protocol & PROT_SMTP) { + if(conn->handler->protocol & CURLPROTO_SMTP) { result = Curl_smtp_escape_eob(conn, nread); if(result) return result; @@ -946,6 +966,14 @@ static CURLcode readwrite_upload(struct SessionHandle *data, Curl_debug(data, CURLINFO_DATA_OUT, data->req.upload_fromhere, (size_t)bytes_written, conn); + k->writebytecount += bytes_written; + + if(k->writebytecount == data->set.infilesize) { + /* we have sent all data we were supposed to */ + k->upload_done = TRUE; + infof(data, "We are completely uploaded and fine\n"); + } + if(data->req.upload_present != bytes_written) { /* we only wrote a part of the buffer (if anything), deal with it! */ @@ -967,7 +995,6 @@ static CURLcode readwrite_upload(struct SessionHandle *data, } } - k->writebytecount += bytes_written; Curl_pgrsSetUploadCounter(data, k->writebytecount); } while(0); /* just to break out from! */ @@ -1520,11 +1547,6 @@ CURLcode Curl_posttransfer(struct SessionHandle *data) (void)data; /* unused parameter */ #endif - if(!(data->progress.flags & PGRS_HIDE) && - !data->progress.callback) - /* only output if we don't use a progress callback and we're not hidden */ - fprintf(data->set.err, "\n"); - return CURLE_OK; } @@ -2052,7 +2074,8 @@ CURLcode Curl_retry_request(struct connectdata *conn, /* if we're talking upload, we can't do the checks below, unless the protocol is HTTP as when uploading over HTTP we will still get a response */ - if(data->set.upload && !(conn->protocol&(PROT_HTTP|PROT_RTSP))) + if(data->set.upload && + !(conn->handler->protocol&(CURLPROTO_HTTP|CURLPROTO_RTSP))) return CURLE_OK; if(/* workaround for broken TLS servers */ data->state.ssl_connect_retry || @@ -2076,6 +2099,9 @@ CURLcode Curl_retry_request(struct connectdata *conn, prevent i.e HTTP transfers to return error just because nothing has been transfered! */ + + if(data->state.proto.http->writebytecount) + Curl_readrewind(conn); } return CURLE_OK; } |