Zinc HTTP Components is an open-source Smalltalk framework to deal with the HTTP networking protocol. This is a new project (started September 1st 2010) that is currently under heavy development. Our long term goals are very ambitious: we want to reach the level of functionality, scope, architectural clarity and maturity of the Apache HTTP Components library. Our short term goal is to offer working HTTP client functionality to support fundamental features in a Smalltalk image. For the time being, Pharo is our reference platform.
Today I read a mail from the author of Zinc, Sven Van Caekenberghe in the Pharo list, about the status of the framework then I had the idea of write this small article highlighting the Zinc features and status.
Next the afore mentioned mail:
Hi,
This is a list of the most important changes to Zn since May 1st 2011:
- added brand new ZnClient to replace all other HTTP clients (who became deprecated)
this is an object to build, execute and process HTTP client requests,
it has a rich protocol to construct requests and to access responses,
it has various error handling options,
it can reuse an existing connection to a specific host:port,
it can handle sessions, cookies, redirects and authentication,
it has many options (settings) with sensible defaults.
here is the simplest example:
ZnClient new
get: 'http://zn.stfx.eu/zn/numbers.
and here is an example using some features to make a better HTTP request:
ZnClient new
systemPolicy;
accept: ZnMimeType textPlain;
http;
host: 'zn.stfx.eu';
path: 'zn/numbers.txt';
contentReader: [ :entity | entity contents lines collect: [ :each | each asNumber ] ];
ifFail: [ :exception | self inform: 'I am sorry: ', exception printString ];
get
- added support so that HTTPS works out of the box if Zodiac is present.
this should work when Zodiac is loaded and the necessary plugin is present:
ZnClient new
url: 'https://www.google.com/search
queryAt: 'q' put: 'Pharo Smalltalk';
get
- added a new subclass, ZnManagingMultiThreadedServer, that keeps track of open
worker connections so that they can be properly closed when needed.
to use this server with the Zn Seaside adaptor, you can do this:
ZnZincServerAdaptor new
port: 8080;
serverClass: ZnManagingMultiThreadedServer;
start
- refactored ZnNetworkingUtils, it is now (also) a factory for creating socket streams
- added ZnDispatcherDelegate for straight-forward dispatching to mapped urls (thx Nick Ager)
- cleanup of the cookie handling API
- fixed support for HTTP proxies (thx Alexandre Bergel for reporting)
- localhost URLs are now excluded from being proxied
- working around SocketStream>>#atEnd issues by using #peek
- implemented support for proxies that require authorization
- introduced ZnConnectionTimeout process variable
- added ManagedServers class variable to ZnServer to dispatch the system's
#startUp/#shutDown messages to all server instances that are #register-ed
- implemented client side support for If-Modified-Since and Not Modified
- changed ZnMimePart>>#fieldValueString to return an empty string instead of 'nil'
when the field is empty or absent (Thx Lukas Renggli)
- added support for dealing with certain defaults in ZnUrl
- added code to throw a ZnMissingHost exception when a bogus ZnUrl is used to connect to a HTTP host
- added ZnMimeType wildcard constants #any and #text
- added ZnHttpUnsuccessful and ZnUnexpectedContentType exceptions
- added a nice example to ZnEasy class>>#getPng: (Thx Lukas Renggli)
- added ZnUtils class>>#parseHttpDate: for use in ZnCookie>>#expiresTimeStamp
- added optional delegate #close-ing to ZnServer hierarchy
- added some Pharo 1.2 compatibility (ZnMultiThreadedServer>>#
- lots of small fixes, cleanup and improved documentation.
And don't miss the Getting Started guide!
Indeed this is a very good framework, not only by its features, but also for it technical quality and the commitment of the developer, taking care of the support and documentation.
I should reimplement XMLRPC to use Zinc. Hope to have time soon.
Pic Info:
http://www.flickr.com/photos/kodomut/3950770038/ / License