Closed wfatp closed 7 years ago
Maybe there is some cookie involved here.
Can you try with (http-get url redirect: #f)
and check the request status and cookies?
I can add support for tracking cookies upon redirect.
[georgiy@PANTHER ~]$ gxi Gerbil v0.12-DEV on Gambit v4.8.8
(import :std/net/request) (def response (http-get "http://debian.org" redirect: #f)) (request-cookies response) () (request-status response) 301
Also why is the function even called request-status? Requests don't have status codes, only responses do.
The function is called request-status because the object is called request.
So the issue seem to be in the headers containing a wrong host I think. This works:
> (http-get "http://debian.org" redirect: #f)
#<request #7>
> (request-headers #7)
(("Date" . "Fri, 08 Sep 2017 22:01:25 GMT")
("Server" . "Apache")
("X-Content-Type-Options" . "nosniff")
("X-Frame-Options" . "sameorigin")
("Referrer-Policy" . "no-referrer")
("X-Xss-Protection" . "1")
("Location" . "http://www.debian.org/")
("Content-Length" . "290")
("Connection" . "close")
("Content-Type" . "text/html; charset=iso-8859-1"))
> (http-get "http://www.debian.org" redirect: #f)
#<request #8>
> (request-headers #8)
(("Date" . "Fri, 08 Sep 2017 22:01:44 GMT")
("Server" . "Apache")
("Content-Location" . "index.en.html")
("Vary" . "negotiate,accept-language,Accept-Encoding")
("Tcn" . "choice")
("X-Content-Type-Options" . "nosniff")
("X-Frame-Options" . "sameorigin")
("Referrer-Policy" . "no-referrer")
("X-Xss-Protection" . "1")
("Last-Modified" . "Wed, 06 Sep 2017 11:34:34 GMT")
("Etag" . "\"3be8-55883ba5b59fc-gzip\"")
("Accept-Ranges" . "bytes")
("Content-Encoding" . "gzip")
("Cache-Control" . "max-age=86400")
("Expires" . "Sat, 09 Sep 2017 22:01:44 GMT")
("X-Clacks-Overhead" . "GNU Terry Pratchett")
("Content-Length" . "4735")
("Connection" . "close")
("Content-Type" . "text/html")
("Content-Language" . "en"))
> (request-status #8)
200
> (request-status #7)
301
Fixed by #25; thanks for reporting the bug!
Thank you for fixing. :-)
Unfortunately requesting pages seems to be hit and miss:
[georgiy@PANTHER ~]$ gxi Gerbil v0.12-DEV on Gambit v4.8.8
For some reason it's not able to get the Debian home page among others the way any of my browsers can and the way I can get with Python's Requests library.