I'm currently trying to port one of my Python scripts which downloads the latest crossword from a newspaper site. Online the crossword is accessed via a URL like: "http://site.com/crossword/latest/" which automatically redirects to the URL of the latest crossword, a URL like: "http://site.com/crossword/4213/"
So, for testing, I've got:
response := http.get("http://site.com/crossword/latest/") or {panic('ERR')}
println("DEBUG: response status => $response.status_code")
println("DEBUG: response headers => $response.headers")
println("DEBUG: response text => $response.
text")
but neither is giving me any output at all:
DEBUG: response status => 0
DEBUG: response headers => {}
DEBUG: response text =>
The connection seems to be being made OK as I don't get any error [and it works fine with other non-redirecting URLs]. I would have expected to at least get a 301: moved permanently
status_code response.
Anyone got any pointers as to how I can return the resulting URL after the redirection, or otherwise handle a URL which redirects?
Incidentally, I initially had a similar problem when writing the original Python version. But there I was able to use:
(urllib.request.urlopen("http://site.com/crossword/latest/")).geturl()
...to return the URL I eventually get redirected to. Not sure how [or if] that could be translated into what's currently available in V.