[squeak-dev] Re: WebClient does not seem to provide any way of getting the terminating, absolute URL of a response

Andreas Raab andreas.raab at gmx.de
Wed Aug 25 04:50:54 UTC 2010


On 8/24/2010 2:12 AM, jaayer wrote:
> I need to be able to write something like this:
>
> aResponse := WebClient httpGet: aUrl.
>
> and have some message I can send to aResponse to get the URL of the resource at which the request terminated. That means if aUrl was "http://google.com", then sending the proposed message to aResponse should yield "http://www.google.com," as a request for the former results in a redirection (301) to the latter. This is doable with HTTPSocket:
>
> (HTTPSocket httpGetDocument: 'http://google.com') url
>
> (which yields "http://www.google.com")
>
> The information for the scheme could come from WebClient itself, as could the hostname (although HTTP 1.1 makes the Host field mandatory). I think it would be nice if both WebRequest and WebResponse could give you absolute URLs representing them. "finalUrl" was probably a poor choice of name; "absoluteUrl" would be better.

I've done just that, and if you update WebClient from the repository you 
will now be able to find out the final url by doing:

resp := WebClient httpGet: 'http://squeaksource.com/WebClient.html'.
resp url

=>'http://squeaksource.com/@qvbZrGJEgfjgaKS8/FoGS9Ilj'

Thank you for this suggestion.

Cheers,
   - Andreas



More information about the Squeak-dev mailing list