Calling REST APIs from Squeak

Lex Spoon lex at lexspoon.org
Sat Mar 24 19:59:42 UTC 2007


"Benjamin Pollack" <benjamin.pollack at gmail.com> writes:
> I was talking to the author of a book on REST the other day, and noticed
> that neither HTTPClient nor HTTPSocket really seem to support REST APIs. At
> a bare minimum, I think you'd probably want the ability to add arbitrary
> headers to GET/PUT/POST (which HTTPSocket doesn't allow) and the ability to
> issue DELETE commands. For example, Amazon's APIs require an Authorization:
> header, and writing a clean WebDAV client that didn't duplicate a huge chunk
> of HTTPSocket functionality would be impossible at the moment. I'd be happy
> to submit a changeset refactoring HTTPSocket to make this more feasible, but
> I wanted to verify that I'm not either misunderstanding how these classes
> are supposed to be used or missing existing functionality already in the
> image.


HTTPSocket is really very minimal.  No one that I know of has taken
the time to factor out a proper HTTP client out of it.

A great start would be to make an HTTPRequest object out of all the
parameters of all the methods on the class side.  One for the URL, one
for GET vs. PUT, one for form arguments, one for authentication info,
etc.

Then you could send "retrieve" or something to a request, and get
the response back.

Once to that stage, it would be really easy to add the extra control
you describe, e.g. adding raw HTTP headers.

Lex





More information about the Squeak-dev mailing list