get-url can't return 302 status code

Started by winger, April 14, 2013, 11:52:14 PM

Previous topic - Next topic

winger

Sometimes we need get  http status code .

But get-url  only return 404 status code.


Quote
> (setf xo2 (get-url "http://www.baidu.com/link?url=kX6MGJqjJ4zBBpC8yDF8xDhzsTii46BoCipLx6xJ2t3626ZBIWUltBgpQyK">http://www.baidu.com/link?url=kX6MGJqjJ ... WUltBgpQyK">http://www.baidu.com/link?url=kX6MGJqjJ4zBBpC8yDF8xDhzsTii46BoCipLx6xJ2t3626ZBIWUltBgpQyK" "list debug" 10000 ))

GET /link?url=kX6MGJqjJ4zBBpC8yDF8xDhzsTii46BoCipLx6xJ2t3626ZBIWUltBgpQyK HTTP/1.1

Host: http://www.baidu.com">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: nginxrnDate: Mon, 15 Apr 2013 06:44:58 GMTrnContent-Type: text/htmlrnContent-Length: 24308rnLast-Modified: Mon, 15 Apr 2013 04:46:20 GMTrnConnection: closernETag: "516b861c-5ef4"rnAccept-Ranges: bytesrnrn"

 [text] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">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">http://m.




Request process:


Quote
Request :

GET /link?url=kX6MGJqjJ4zBBpC8yDF8xDhzsTii46BoCipLx6xJ2t3626ZBIWUltBgpQyK HTTP/1.1

User-Agent: Opera/9.80 (X11; Linux i686) Presto/2.12.388 Version/12.15

Host: http://www.baidu.com">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">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\">//http://www.cngrayhat.org

Lutz

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



> (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 GMTrnServer: Apache/2.2rnContent-Type: text/htmlrnVia: 1.1 vhost.phx
.nearlyfreespeech.net:3128 (squid/2.7.STABLE7)rnConnection: closernrn"
>


This example also shows how get-url automatically handles redirects on status code 301.

winger

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



>(get-url "http://newlisp.org">http://newlisp.org" "header debug")

HEAD / HTTP/1.1

Host: newlisp.org

User-Agent: newLISP v10407

Connection: close



HEAD / HTTP/1.1

Host: http://www.newlisp.org">www.newlisp.org

User-Agent: newLISP v10407

Connection: close



"Date: Tue, 16 Apr 2013 10:56:53 GMTrnServer: Apache/2.2rnContent-Type: text/htmlrnVia: 1.1 vhost.phx1.nearlyfreespeech.net:3128 (squid/2.7.STABLE7)rnConnection: closernrn"



Problems caused by the operating system?



Problems caused by the operating system?
Welcome to a newlisper home:)

http://www.cngrayhat.org\">//http://www.cngrayhat.org

Lutz

#3
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/development/inprogress/">http://www.newlisp.org/downloads/develo ... nprogress/">http://www.newlisp.org/downloads/development/inprogress/



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.