cURL / Mailing Lists / curl-users / Single Mail

curl-users

cURL does not redirect properly

From: ykhuang <yk-huang_at_prolific.com.tw>
Date: Tue, 28 Jun 2005 18:10:08 +0800

Hi,

I'm writing a script to automatically login on some server. After login
correctly, the server will
response with a redirect URL like below(captured by LiveHTTPHeader).

---------------------------------------------------------------------------------------------------------------
HTTP/1.x 302 Moved Temporarily
Server: Netscape-Enterprise/4.1
Date: Tue, 28 Jun 2005 07:55:54 GMT
Location:
http://websms1.emome.net/sms/sendsms/index2.jsp?nop=emome&lang=html&subno=0919705048*&BV_SessionID=@@@@1055829933.1119945333@@@@&BV_EngineID=ccdladdemlheljecefeceefdffidgoj.0&trans_id=5235-1119945333-226&mac=410768&emomeCTime=2001/06/20
16:43:00
Pragma: no-cache, no-cache
Cache-Contorl: no-cache
Cache-Control: no-cache
Expires: Mon, 01 Jan 1990 00:00:00 GMT, Mon, 01 Jan 1990 00:00:00 GMT
Content-Length: 0
---------------------------------------------------------------------------------------------------------------

cURL could redirect to the location correctly. But there's second
redirect URL after the first one.
Something wrong here.

--------------------------------------------------------------------------------------------------------------------
* About to connect() to websms1.emome.net:80
* Connected to websms1.emome.net (211.79.38.83) port 80
> GET
/sms/sendsms/index2.jsp?nop=emome&lang=html&subno=0919705048*&BV_SessionID=@@@@1479415263.1119947546@@@@&BV_EngineID=ccdcaddemgfhjjlcefeceefdffidgoj.0&trans_id=5235-1119947546-147&mac=410768&emomeCTime=2001/06/20
16:43:00 HTTP/1.1
User-Agent: curl/7.9.8 (i386-redhat-linux-gnu) libcurl 7.9.8 (OpenSSL
0.9.7a) (ipv6 enabled)
Host: websms1.emome.net
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*

HTTP/1.0 200 OK
Server: Resin/2.1.11
Expires: Tue, 20 Aug 1996 14:25:27 GMT
Pragma: no-cache
Set-Cookie: JSESSIONID=c_sTIQeeHWa5; path=/
Content-Type: text/html; charset=Big5
Content-Length: 30
Date: Tue, 28 Jun 2005 08:56:14 GMT
--------------------------------------------------------------------------------------------------------------------

Above was logged by cURL. It got a response 200 OK but not 302 from
server. Then it stopped by getting several blank lines as output.
Compared to the log below captured by LiveHTTPHeader:

--------------------------------------------------------------------------------------------------------------------
http://websms1.emome.net/sms/sendsms/index2.jsp?nop=emome&lang=html&subno=0919705048*&BV_SessionID=@@@@1055829933.1119945333@@@@&BV_EngineID=ccdladdemlheljecefeceefdffidgoj.0&trans_id=5235-1119945333-226&mac=410768&emomeCTime=2001/06/20%2016:43:00

GET
/sms/sendsms/index2.jsp?nop=emome&lang=html&subno=0919705048*&BV_SessionID=@@@@1055829933.1119945333@@@@&BV_EngineID=ccdladdemlheljecefeceefdffidgoj.0&trans_id=5235-1119945333-226&mac=410768&emomeCTime=2001/06/20%2016:43:00
HTTP/1.1
Host: websms1.emome.net
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8)
Gecko/20050511 Firefox/1.0.4
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer:
http://www.emome.net/cgi-bin/MASP/jsp/membersvc/AuthServlet?serviceId=5235&com.broadvision.session.new=Yes

HTTP/1.x 302 Found
Server: Resin/2.1.11
Cache-Control: private
Expires: Tue, 20 Aug 1996 14:25:27 GMT
Pragma: no-cache
Location: http://websms1.emome.net/sms/sendsms/new.jsp?msg=
Set-Cookie: JSESSIONID=cSsDNyYkWDb-; path=/
Content-Type: text/html; charset=Big5
Content-Length: 88
Date: Tue, 28 Jun 2005 07:55:55 GMT
--------------------------------------------------------------------------------------------------------------------

cURL should be noticed to redirect to second URL but it didn't. What
should I do to get correct response from server?
Any hint is welcome.
Received on 2005-06-28