astaxie / bat

Go implement CLI, cURL-like tool for humans
Apache License 2.0
2.55k stars 220 forks source link

301 redirect issue #24

Closed micanzhang closed 9 years ago

micanzhang commented 9 years ago

when i request http://v.pptv.com with curl command line tool, i got this:

$curl -I http://v.pptv.com
HTTP/1.1 301 Moved Permanently
Date: Wed, 22 Apr 2015 15:02:51 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Cache-Control: no-cache
Location: http://www.pptv.com
Age: 1
Via: http/1.1 shnj-b-ats-157-223-2 (ATS/1.2.2 [uScMsSf pSeN:t cCMi p sS]),  http/1.1 sh-i-ats-8-44-1 (ATS/1.2.0 [uScMsSf pSeN:t cCMi p sS])

but when i try with bat, then:

bat head http://v.pptv.com
HEAD / HTTP/1.1
Host: v.pptv.com
Accept: application/json
Accept-Encoding: gzip, deflate
User-Agent: bat/0.0.2

HTTP/1.1 200 OK
Expires : Wed, 22 Apr 2015 15:21:32 GMT
Age : 278
Connection : keep-alive
Last-Modified : Wed, 22 Apr 2015 15:01:32 GMT
Cache-Control : public, max-age=1200
Vary : Accept-Encoding Accept-Encoding Accept-Encoding Accept-Encoding
Via : http/1.1 shnj-b-ats-157-223-2 (ATS/1.2.2 [uIcRs f p eN:t cCHi p s ]),     http/1.1 sh-i-ats-8-45-1 (ATS/1.2.0 [uScRs f p eN:t cCHi p s ])
Content-Length : 714354
Date : Wed, 22 Apr 2015 15:06:09 GMT
Content-Type : text/html; charset=utf-8
Pragma : public

and i try write a small demo with net/http package, i got the same result with bat, so i guess net/http handle this. but i think return origin redirect info not redirect directly.

astaxie commented 9 years ago

yea, net/http has the default value for redirect.