From 3a499099af52ddc69a3647767521c99c9e9c42e4 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 4 Aug 2008 22:00:22 +0000 Subject: - Test cases 1051, 1052 and 1055 were added by Daniel Fandrich on July 30 and proved how PUT and POST with a redirect could lead to a "hang" due to the data stream not being rewound properly when it had to in order to get sent properly (again) to the subsequent URL. This is now fixed and these test cases are no longer disabled. --- lib/http.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'lib/http.c') diff --git a/lib/http.c b/lib/http.c index 195d661d6..173de8edc 100644 --- a/lib/http.c +++ b/lib/http.c @@ -309,7 +309,7 @@ static bool pickoneauth(struct auth *pick) } /* - * perhapsrewind() + * Curl_http_perhapsrewind() * * If we are doing POST or PUT { * If we have more data to send { @@ -331,18 +331,29 @@ static bool pickoneauth(struct auth *pick) * } * } */ -static CURLcode perhapsrewind(struct connectdata *conn) +CURLcode Curl_http_perhapsrewind(struct connectdata *conn) { struct SessionHandle *data = conn->data; struct HTTP *http = data->state.proto.http; curl_off_t bytessent; curl_off_t expectsend = -1; /* default is unknown */ - if(!http) + if(!http || !(conn->protocol & PROT_HTTP)) /* If this is still NULL, we have not reach very far and we can - safely skip this rewinding stuff */ + safely skip this rewinding stuff, or this is attempted to get used + when HTTP isn't activated */ return CURLE_OK; + infof(data, "now in %s\n", __func__); + + switch(data->set.httpreq) { + case HTTPREQ_GET: + case HTTPREQ_HEAD: + return CURLE_OK; + default: + break; + } + bytessent = http->writebytecount; if(conn->bits.authneg) @@ -453,7 +464,7 @@ CURLcode Curl_http_auth_act(struct connectdata *conn) if((data->set.httpreq != HTTPREQ_GET) && (data->set.httpreq != HTTPREQ_HEAD) && !conn->bits.rewindaftersend) { - code = perhapsrewind(conn); + code = Curl_http_perhapsrewind(conn); if(code) return code; } -- cgit v1.2.3