[squeak-dev] WebClient httpGet with pre-encoded url's
Jan van de Sandt
jvdsandt at gmail.com
Mon Aug 9 14:32:58 UTC 2010
I am busy updating the CloudforkAWS code to use WebClient as a the HTTP
client. CloudforkAWS provides a Smalltalk API to the Amazon AWS REST
WebClient works really well, the not so common HTTP methods like HEAD,
DELETE and PUT that the Simple Storage Service (S3) require work without any
There is only one small problem. The WebClient>>httpGet:do: method always
encodes the urlString. In my situation the url is already encoded and
encoding it a second time leads to errors. In my code I encode the
individual query parameters names and values before I compose the complete
url. If you have a parameters like this I think it is the only correct way:
param2=coming for dinner?
So I added the following methods to WebClient:
httpGet: urlString encoded: isEncoded do: aBlock
"GET the response from the given url"
| request |
self initializeFromUrl: urlString.
request := self requestWithUrl: urlString encoded: isEncoded.
request method: 'GET'.
userAgent ifNotNil:[request headerAt: 'User-Agent' put: userAgent].
aBlock value: request.
^self sendRequest: request
requestWithUrl: urlString encoded: isEncoded
"Create an return a new WebRequest initialized with the given url.
Subclasses can use this method to override the default request class."
^WebRequest new initializeFromUrl: urlString encoded: isEncoded.
It would be great if these methods are incorporated in the base package.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev