. .


ST 4U 194: HTTP Queries in VA Smalltalk

February 15, 2012 11:29:38.719

Today's Smalltalk 4 You looks at client level HTTP again in VA Smalltalk - specifically, how to make such usage simpler. We also take a brief look at using proxy servers. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:


If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Today we'll go back to HTTP queries in VA Smalltalk. As it happens, there's a simpler way to do queries than getting the client, starting it up, and shutting it down. Instead of this:

"Set up a client for http, execute a request"
client := (SstHttpClient  forTransportScheme: 'http') startUp.
response := 
	[client get: 'http://www.jarober.com']
	ensure: [client shutDown].

We can do this:

url := 'http://www.jarober.com/'.
response := url sstAsUrl fetch.

If you trace through the execution, you'll see that it does the same thing as the more complex looking code - but it's a whole lot simpler to use. Once you do that, you should see something like this:

HTTP Query

We can't really demonstrate proxy server usage, as the network used here doesn't have that. However, it's pretty straightforward. Simply use the following:

"proxy setup"
(SstTransport configurationRegistry at: 'httpl')
proxyUrl: ('http://proxy.myco.com:8080') sstAsUrl.

and then execute requests normally - you'll then be using your proxy server.

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Technorati Tags: , ,

[st4u194-iPhone.m4v ( Size: 4607491 )]

posted by James Robertson

 Share Tweet This