diff options
author | Daniel Stenberg <daniel@haxx.se> | 2003-06-06 14:58:26 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2003-06-06 14:58:26 +0000 |
commit | 8d30d34e0cc45376bb95de46d42a786c2c362e8a (patch) | |
tree | 766e646c7f7ff53dd347ac6c266c507b5c01cb65 | |
parent | bc7fe85f8a907673b5c91a8d92fdc0f1a08e4de0 (diff) |
When doing very big GET requests over HTTPS, we need to add some extra
funky logic in order to make re-tries work fine with OpenSSL. This corrects
the problem David Orrell noticed.
-rw-r--r-- | lib/http.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/http.c b/lib/http.c index 408cbafc5..16a87d937 100644 --- a/lib/http.c +++ b/lib/http.c @@ -191,6 +191,7 @@ CURLcode add_buffer_send(send_buffer *in, char *ptr; int size; struct HTTP *http = conn->proto.http; + int sendsize; /* The looping below is required since we use non-blocking sockets, but due to the circumstances we will just loop and try again and again etc */ @@ -198,7 +199,28 @@ CURLcode add_buffer_send(send_buffer *in, ptr = in->buffer; size = in->size_used; - res = Curl_write(conn, sockfd, ptr, size, &amount); + if(conn->protocol & PROT_HTTPS) { + /* We never send more than CURL_MAX_WRITE_SIZE bytes in one single chunk + when we speak HTTPS, as if only a fraction of it is sent now, this data + needs to fit into the normal read-callback buffer later on and that + buffer is using this size. + */ + + sendsize= (size > CURL_MAX_WRITE_SIZE)?CURL_MAX_WRITE_SIZE:size; + + /* OpenSSL is very picky and we must send the SAME buffer pointer to the + library when we attempt to re-send this buffer. Sending the same data + is not enough, we must use the exact same address. For this reason, we + must copy the data to the uploadbuffer first, since that is the buffer + we will be using if this send is retried later. + */ + memcpy(conn->data->state.uploadbuffer, ptr, sendsize); + ptr = conn->data->state.uploadbuffer; + } + else + sendsize = size; + + res = Curl_write(conn, sockfd, ptr, sendsize, &amount); if(CURLE_OK == res) { |