[squeak-dev] Re: [ANN] WebClient and WebServer 1.0 for Squeak

Andreas Raab andreas.raab at gmx.de
Wed May 12 03:55:37 UTC 2010


On 5/11/2010 2:36 PM, Igor Stasenko wrote:
> On 11 May 2010 19:22, Andreas Raab<andreas.raab at gmx.de>  wrote:
>> What other methods do you need? There should be no problem adding any I just
>> had no need for them initially.
>>
> As far as i can tell,
>
> CouchDB API using PUT, POST, GET, DELETE methods.
>
> (http://wiki.apache.org/couchdb/API_Cheatsheet)

All of those are now covered by the latest WebClient. In addition to 
GET, POST, PUT and DELETE, WebClient also supports HEAD, TRACE, and 
OPTIONS.

Plus, this forced me to deal with HTTP methods in WebServer correctly 
which is great since it means you can now specify what methods should 
apply to a given resource, e.g.,

	server := WebServer reset default.
	server listenOn: 8080.
	server addService: '/foo' action:[:req|
		req send200Response: 'OK'
	] methods: {'GET'. 'PUT'. 'DELETE'}. "GET/PUT/DELETE are allowed but no 
POST"

Now, you can do, e.g.,

	WebClient httpGet: 'http://localhost:8080/foo'.
	  "=> 200 OK"

but POSTs are not allowed:

	WebClient httpPost: 'http://localhost:8080/foo' content: '' type:''.
	  "=> 405 Method Not Allowed"

However, since OPTIONS is supported you can ask for the supported 
operations of the resource:

	WebClient httpOptions: 'http://localhost:8080/foo'.
	  "=> allow: HEAD,TRACE,OPTIONS,GET,PUT,DELETE"

and for the default server options:

	WebClient httpOptions: 'http://localhost:8080/*'.
	  "=> allow: HEAD,TRACE,OPTIONS,GET,POST"

Nice forcing function, thanks!

Cheers,
   - Andreas



More information about the Squeak-dev mailing list