This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: Doing an Http Post
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Awhile back, I made a post about HTTP Queries from VisualWorks. Let's have a look at how an HTTP Post would look. You are going to end up working with the same HttpClient (or HttpsClient) class as before - and you are going to need to craft a custom Request object. Let's presume that the post is like a post from a form - here's what we need to do:
Now, you wouldn't want to hard code the encoding, or the data (or the URL). In the Http-Access and NetResources packages (in the Public Store), there's a simple API for doing posts with that data passed in. Encoding the data is a fairly simple thing; you need something like this:
That will give you back a string suitable for passing as an url encoded string in a POST form. That's pretty much it though. By mucking around with the encoding and the data being passed, you can create any kind of POST request pretty easily. Next time I'll take a look at the way such a post might be handled by a VisualWorks Web Toolkit servlet.