cURL / Mailing Lists / curl-users / Single Mail

curl-users

curl hangs after redirected HTTP PUT

From: Ben Sutcliffe <lists.ben_at_gmail.com>
Date: Tue, 29 Jul 2008 18:36:15 -0400

I have two Apache 2 virtual hosts: www1 and www2

www1:
* PHP script redirects all HTTP PUT requests to www2 by sending back a
HTTP response with code 307 and a "Location" header

www2:
* PHP script processes all HTTP PUT requests by writing the HTTP PUT
payload to the the given URL.

Everything seems to work fine
1. curl sends HTTP PUT to www1
2. www1 sends back HTTP 307
3. curl sends HTTP PUT to www2
4. www2 writes HTTP PUT payload to the specified location

Problem:
After curl receives the final HTTP/1.1 100 Continue from www2, curl
just hangs there waiting for something (maybe HTTP GET payload
data...even though no HTTP GET was issued?). When I use "-m 2" on the
curl command-line, curl exits with code 28 and the following message:
curl: (28) Operation timed out after 2000 milliseconds with 0 bytes received

When I do an HTTP PUT directly to www2 (i.e., without a redirect from
www1), everything works fine and curl exits as expected.

*************
NOTE: I made sure that I used a 3xx code of 307, which is greater than
303 to ensure that an HTTP PUT is issued for the redirected URL
instead of a GET.

Here's an extract from the curl manual in regards to the "-L"
command-line param:

"When curl follows a redirect and the request is not a plain GET
(for example POST or PUT), it will do the following request with a GET
if the HTTP response was 301, 302, or 303. If the response code was
any other 3xx code, curl will re-send the following request using the
same unmodified method."
*************

Here's the console output when I use the "-v" command-line param.

prompt> curl -m 2 -v -L -T hello.txt http:/www1/hello.txt
* About to connect() to www1 port 80 (#0)
* Trying 127.0.0.2... connected
* Connected to www1 (127.0.0.2) port 80 (#0)
> PUT /hello.txt HTTP/1.1
> User-Agent: curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1
> Host: www1
> Accept: */*
> Content-Length: 12
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
< HTTP/1.1 307 Temporary Redirect
< Date: Tue, 29 Jul 2008 21:43:38 GMT
< Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.3 with Suhosin-Patch
< X-Powered-By: PHP/5.2.4-2ubuntu5.3
< Location: http://www2/hello.txt
< Content-Length: 0
< Content-Type: text/html
<
* Connection #0 to host www1 left intact
* Issue another request to this URL: 'http://www2/hello.txt'
* About to connect() to www2 port 80 (#1)
* Trying 127.0.0.3... connected
* Connected to www2 (127.0.0.3) port 80 (#1)
> PUT /hello.txt HTTP/1.1
> User-Agent: curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1
> Host: www2
> Accept: */*
> Content-Length: 12
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
* Operation timed out after 2000 milliseconds with 0 bytes received
* Closing connection #1
curl: (28) Operation timed out after 2000 milliseconds with 0 bytes received
* Closing connection #0

***************************

This behavior is present in the latest daily snapshot.

output of "curl -V":

curl 7.19.0-20080729 (i686-pc-linux-gnu) libcurl/7.19.0-20080729
OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1
Protocols: tftp ftp telnet dict http file https ftps
Features: IDN IPv6 Largefile NTLM SSL libz

****************************

Using the "-m" option is not an acceptable workaround because I plan
on uploading multi-gigabyte files and I can't put a hard-limit on the
file upload time. I'd like to see curl exit after the upload is
complete.

Any thoughts?

Thanks
Ben
-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2008-07-30