get-url can't return 302 status code

Q&A's, tips, howto's
Locked
winger
Posts: 46
Joined: Wed Mar 14, 2012 7:31 am

get-url can't return 302 status code

Post by winger »

Sometimes we need get http status code .
But get-url only return 404 status code.
> (setf xo2 (get-url "http://www.baidu.com/link?url=kX6MGJqjJ ... WUltBgpQyK" "list debug" 10000 ))
GET /link?url=kX6MGJqjJ4zBBpC8yDF8xDhzsTii46BoCipLx6xJ2t3626ZBIWUltBgpQyK HTTP/1.1
Host: www.baidu.com
User-Agent: newLISP v10406
Connection: close

GET /x_8ce9a63e HTTP/1.1
Host: shenzhen.8684.cn
User-Agent: newLISP v10406
Connection: close

("Server: nginx\r\nDate: Mon, 15 Apr 2013 06:44:58 GMT\r\nContent-Type: text/html\r\nContent-Length: 24308\r\nLast-Modified: Mon, 15 Apr 2013 04:46:20 GMT\r\nConnection: close\r\nETag: \"516b861c-5ef4\"\r\nAccept-Ranges: bytes\r\n\r\n"
[text] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <meta http-equiv="mobile-agent" content="format=xhtml; url=http://m.

Request process:
Request :
GET /link?url=kX6MGJqjJ4zBBpC8yDF8xDhzsTii46BoCipLx6xJ2t3626ZBIWUltBgpQyK HTTP/1.1
User-Agent: Opera/9.80 (X11; Linux i686) Presto/2.12.388 Version/12.15
Host: www.baidu.com
Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Accept-Encoding: gzip, deflate
Cookie: bdshare_firstime=1358503823802; PMS_Cache=1363532395084; BDRCVFR[1YH7NbrCiJt]=mk3SLVN4HKm; BDRCVFR[4h1EqrJ1R8f]=VvV1HAYMbPTULK-Th7WpA-8mi4WUvY; BAIDUID=F213C9E903147ACDC369E0D0DA6B84D1:FG=1; BAIDU_WISE_UID=bd_1355838599_729; BDUT=l09eF8F6C6A8ED1A60168F8E527DBCD7548213d05aacbdee; H_PS_PSSID=2218_1439_1944_1788_2222
Connection: Keep-Alive


Respone:
HTTP/1.1 302 Found
Date: Mon, 15 Apr 2013 06:47:49 GMT
Server: Apache
Location: http://shenzhen.8684.cn/x_8ce9a63e
Cache-Control: max-age=86400
Expires: Tue, 16 Apr 2013 06:47:49 GMT
Content-Length: 218
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">........
Welcome to a newlisper home:)
http://www.cngrayhat.org

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: get-url can't return 302 status code

Post by Lutz »

The status is now displayed too when including the debug option:

Code: Select all

> (get-url "http://newlisp.org" "header debug")
HEAD / HTTP/1.1
Host: newlisp.org
User-Agent: newLISP v10408
Connection: close

HTTP/1.1 301 Moved Permanently

HEAD / HTTP/1.1
Host: http://www.newlisp.org
User-Agent: newLISP v10408
Connection: close

HTTP/1.1 200 OK

"Date: Tue, 16 Apr 2013 06:31:56 GMT\r\nServer: Apache/2.2\r\nContent-Type: text/html\r\nVia: 1.1 vhost.phx
.nearlyfreespeech.net:3128 (squid/2.7.STABLE7)\r\nConnection: close\r\n\r\n"
>
This example also shows how get-url automatically handles redirects on status code 301.

winger
Posts: 46
Joined: Wed Mar 14, 2012 7:31 am

Re: get-url can't return 302 status code

Post by winger »

Don't work!
newLISP v.10.4.7 on Linux IPv4/6 libffi, execute 'newlisp -h' for options.

>(get-url "http://newlisp.org" "header debug")
HEAD / HTTP/1.1
Host: newlisp.org
User-Agent: newLISP v10407
Connection: close

HEAD / HTTP/1.1
Host: www.newlisp.org
User-Agent: newLISP v10407
Connection: close

"Date: Tue, 16 Apr 2013 10:56:53 GMT\r\nServer: Apache/2.2\r\nContent-Type: text/html\r\nVia: 1.1 vhost.phx1.nearlyfreespeech.net:3128 (squid/2.7.STABLE7)\r\nConnection: close\r\n\r\n"
Problems caused by the operating system?

Problems caused by the operating system?
Welcome to a newlisper home:)
http://www.cngrayhat.org

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: get-url can't return 302 status code

Post by Lutz »

These changes are not in 10.4.7 but in the upcoming version 10.4.8, currently in the process of making here:

http://www.newlisp.org/downloads/develo ... nprogress/

in that place you find a newlisp-win.exe, a newlisp-win-utf8.exe and newlisp-osx-intel preview of development version 10.4.8 to be released in May, when I am back in California.

Locked