aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2008-08-04 22:00:22 +0000
committerDaniel Stenberg <daniel@haxx.se>2008-08-04 22:00:22 +0000
commit3a499099af52ddc69a3647767521c99c9e9c42e4 (patch)
tree7c67c35412c825d8c7e6011d0b0fa27e64ca057c /lib
parent931fc45f05e7370fd815c34884863f2b56920b5f (diff)
- 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.
Diffstat (limited to 'lib')
-rw-r--r--lib/http.c21
-rw-r--r--lib/http.h3
-rw-r--r--lib/transfer.c7
3 files changed, 25 insertions, 6 deletions
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;
}
diff --git a/lib/http.h b/lib/http.h
index 5a04f8c43..1c53120dd 100644
--- a/lib/http.h
+++ b/lib/http.h
@@ -8,7 +8,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -57,6 +57,7 @@ void Curl_http_auth_stage(struct SessionHandle *data, int stage);
CURLcode Curl_http_input_auth(struct connectdata *conn,
int httpcode, const char *header);
CURLcode Curl_http_auth_act(struct connectdata *conn);
+CURLcode Curl_http_perhapsrewind(struct connectdata *conn);
int Curl_http_should_fail(struct connectdata *conn);
diff --git a/lib/transfer.c b/lib/transfer.c
index ea6cfa357..330ba7df6 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -1116,6 +1116,12 @@ CURLcode Curl_readwrite(struct connectdata *conn,
data->req.newurl = strdup(data->req.location); /* clone */
if(!data->req.newurl)
return CURLE_OUT_OF_MEMORY;
+
+ /* some cases of POST and PUT etc needs to rewind the data
+ stream at this point */
+ result = Curl_http_perhapsrewind(conn);
+ if(result)
+ return result;
}
}
}
@@ -1570,6 +1576,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* we've waited long enough, continue anyway */
k->exp100 = EXP100_SEND_DATA;
k->keepon |= KEEP_WRITE;
+ infof(data, "Done waiting for 100-continue\n");
}
}
}