Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

http redirects

 [1/3] from: hallvard::ystad::helpinhand::com at: 30-Oct-2001 16:53

Thanks for all the help regarding http (and email) headers. Here's another tricky question: How do I detect http redirects? 'Read follows redirects by default. I need to know what URL was finally downloaded. I have scrutinized the system object as much as I could, but haven't found any values to help me out. I notice that 'page gets set when there's a redirect, but I need also the return code from the server. Has anyone got any experience with this? ~H

 [2/3] from: hallvard:ystad:helpinhand at: 5-Nov-2001 22:07

What is the right way to detect redirects (except trace/net)? Here's a guess:
>> port: open >> port/url
== ""
>> close port
(no redirect)
>> port: open >> port/url
== ""
>> close port
(redirect!) Is there some other way to do it? ~H

 [3/3] from: sterling:rebol at: 5-Nov-2001 14:47

port: open probe port/locals/list probe port/url close port This is the list of redirected url's. There may be more than one. The list is empty if there were no redirects. The list contains al lredirected url's if there were any. The last URL read is not in the list and, as you know, can be found in port/url. So the better one-liner to see if you got redirected after an open is:
>> empty? port/locals/list