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

jaayer jaayer at zoho.com
Wed Aug 25 06:24:43 UTC 2010



---- On Tue, 24 Aug 2010 21:50:54 -0700 Andreas Raab  wrote ---- 

>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 

Thaks; that is exactly what I need. I have also sent you a package containing minor fixes for WebClient-Core.




More information about the Squeak-dev mailing list