[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
Tue Aug 24 09:12:18 UTC 2010



---- On Mon, 23 Aug 2010 20:20:14 -0700 Andreas Raab  wrote ---- 

>Hi - 
> 
>Can you say a little more what you need this URL for? I don't think it 
>makes quite sense to implement it in the way you're suggesting since the 
>scheme would be guesswork (what if it's https or rtsp or something 
>else?) and the host-header might not be present. It seems to me that 
>some context needs be provided (probably) via WebServer to fill in what 
>is needed but for that I'd need to know where you're trying to use the 
>url (i.e., in a server or a client?). 

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.




More information about the Squeak-dev mailing list