cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: redirects and their bodies

From: Michael Wallner <mike_at_iworks.at>
Date: Wed, 27 Jul 2005 16:19:31 +0200

Hi Ralph Mitchell, you wrote:

> I don't mind being proved wrong, but in my experience, when I see a
> bunch of headers with a "Location: [url]" redirect header, there often
> *isn't* a body to return. I mean, the Location header means, "hey, go
> to this other place", so why would there be a body??

Because the RFC recommends it for !HEAD (SHOULD):
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.3

s1-iw:~$ curl -i http://www.google.com
HTTP/1.1 302 Found
Location: http://www.google.de/cxfer?c=PREF%3D:TM%3D1122473717:S%3DEU6uDrNiMIEQnR1I&prev=/
Set-Cookie: ...long line ...
Content-Type: text/html
Server: GWS/2.1
Content-Length: 214
Date: Wed, 27 Jul 2005 14:15:17 GMT

<HTML><HEAD><TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.de/cxfer?c=PREF%3D:TM%3D1122473717:S%3DEU6uDrNiMIEQnR1I&amp;prev=/">here</A>.
</BODY></HTML>

So my application fails because I get an invalid HTTP message from curl
telling me a Content-Length of 214, while I don't get a body... :-/
This might not be a problem in usual cases, but if one enables redirects
for curl one will have some of these truncated messages telling about
a content length without body.

Thanks,

-- 
Michael - < mike(@)php.net >
Received on 2005-07-27