cURL / Mailing Lists / curl-library / Single Mail

curl-library

Problem on HTTP redirect to relative path

From: Woods <woods.biz_at_gmail.com>
Date: Tue, 20 Mar 2012 21:55:30 +0800

Hi,

I noticed a problem on HTTP redirection to relative path.
In brief:
(1) if using http://somehostname/index.php as target url, the redirection
can be performed but the result code/msg is "URL using bad/illegal format
or missing URL". Why is it treated as an illegal url?
(2) if using http://somehosename as target url, libcurl CANNOT handle
redirection in that it requests the same url repeatedly without picking the
relative path from LOCATION header. It means program will block on
curl_easy_perform permanently.
I am seeking your advice on this, is it a known bug or I can do something
to solve it. Thanks.

Please refer to the following HTTP capture for both cases. Do check the
trace for CASE (2) which looks like a bug.

CASE (1)

GET /index.php HTTP/1.1
Host: xxxxx.xxxxx.org
Accept: */*

HTTP/1.1 302 Found
Date: Tue, 20 Mar 2012 13:35:22 GMT
Server: Apache
X-Powered-By: PHP/5.3.7
Location: index.php?id=2
Set-Cookie: TestCookie=3464
Content-Length: 108
Content-Type: text/html

Powered by LAMP.<p>
Host: xxxxx.xxxxx.org <br />
Accept: */* <br />

GET /index.php?id=2 HTTP/1.1
Host: xxxxx.xxxxx.org
Accept: */*
Cookie: TestCookie=3464

HTTP/1.1 200 OK
Date: Tue, 20 Mar 2012 13:35:23 GMT
Server: Apache
X-Powered-By: PHP/5.3.7
Content-Length: 197
Content-Type: text/html

<meta http-equiv="REFRESH" content="0;url=index.php?id=3">Powered by <a
href="http://www.onlamp.com">LAMP</a>.<p>
Host: xxxxx.xxxxx.org <br />
Accept: */* <br />
Cookie: TestCookie=3464 <br />

CASE (2)

GET / HTTP/1.1
Host: xxxxx.xxxxx.org
Accept: */*

HTTP/1.1 302 Found
Date: Tue, 20 Mar 2012 13:41:59 GMT
Server: Apache
X-Powered-By: PHP/5.3.7
Location: index.php?id=2
Set-Cookie: TestCookie=8381
Content-Length: 108
Content-Type: text/html

Powered by LAMP.<p>
Host: xxxxx.xxxxx.org <br />
Accept: */* <br />

GET / HTTP/1.1
Host: xxxxx.xxxxx.org
Accept: */*
Cookie: TestCookie=8381

HTTP/1.1 302 Found
Date: Tue, 20 Mar 2012 13:41:59 GMT
Server: Apache
X-Powered-By: PHP/5.3.7
Location: index.php?id=2
Set-Cookie: TestCookie=6186
Content-Length: 139
Content-Type: text/html

Powered by LAMP.<p>
Host: xxxxx.xxxxx.org <br />
Accept: */* <br />
Cookie: TestCookie=8381 <br />

GET / HTTP/1.1
Host: xxxxx.xxxxx.org
Accept: */*
Cookie: TestCookie=6186

HTTP/1.1 302 Found
Date: Tue, 20 Mar 2012 13:41:59 GMT
Server: Apache
X-Powered-By: PHP/5.3.7
Location: index.php?id=2
Set-Cookie: TestCookie=2745
Content-Length: 139
Content-Type: text/html

Powered by LAMP.<p>
Host: xxxxx.xxxxx.org <br />
Accept: */* <br />
Cookie: TestCookie=6186 <br />

...... Continue repeatedly

-- 
Woods

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-03-20