[Pharo-project] [Progress Report] Zinc HTTP Components
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.txt' 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>>#exceptionSet:) - lots of small fixes, cleanup and improved documentation Sven
thanks sven do you know if we should merge with the latest version in 1.4? Stef On Nov 13, 2011, at 10:56 PM, Sven Van Caekenberghe wrote:
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.txt' 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>>#exceptionSet:) - lots of small fixes, cleanup and improved documentation
Sven
On 14 Nov 2011, at 07:18, Sven Van Caekenberghe wrote:
On 13 Nov 2011, at 23:59, Stéphane Ducasse wrote:
do you know if we should merge with the latest version in 1.4?
Yes we should, the code is in a good state. I will make an issue because we should record the exact version that got integrated.
I 'reopened' http://code.google.com/p/pharo/issues/detail?id=4903
WOW. It is an incredible amount of work. Really really necessary for making Pharo more business friendly. Thanks a lot Sven. All I wish is that you continue with it. Cheers On Mon, Nov 14, 2011 at 6:35 AM, Sven Van Caekenberghe <sven@beta9.be>wrote:
On 14 Nov 2011, at 07:18, Sven Van Caekenberghe wrote:
On 13 Nov 2011, at 23:59, Stéphane Ducasse wrote:
do you know if we should merge with the latest version in 1.4?
Yes we should, the code is in a good state. I will make an issue because we should record the exact version that got integrated.
I 'reopened' http://code.google.com/p/pharo/issues/detail?id=4903
-- Mariano http://marianopeck.wordpress.com
I have been very happily using ZNNeoClient. Does this mean that ZNClient is now the replacement for ZNNeoClient? Thanks S. On Nov 14, 2011, at 5:56 AM, Sven Van Caekenberghe wrote:
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.txt' 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>>#exceptionSet:) - lots of small fixes, cleanup and improved documentation
Sven
participants (4)
-
mail list -
Mariano Martinez Peck -
Stéphane Ducasse -
Sven Van Caekenberghe