Retrieve final URL after redirection



Hi,

I am using soup in Sugar to download a simple webpage over HTTP. This
page includes some links that I parse. Some of those links are
relative e.g. <a href="foo.zip">. If I then go on to download the
content pointed to, I have to resolve that relative link to something
absolute.

To resolve relative links like that, I need to know the URL that the
webpage came from. And that is not necessarily the same as the URL I
requested with soup, because of any HTTP redirects that might have
happened.

What is the best way to get the real URL of the completed SoupMessage
after all redirection has happened?

Is there something better than adding an intermediate header handler
for the Location header and recording the URL of the most recent
redirect myself? That might even be a bit complicated as apparently
Location header can maybe include relative URLs themselves, see
http://en.wikipedia.org/wiki/HTTP_location

Thanks
Daniel


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]