[Seaside-dev] WAComboResponse + Zinc

Sven Van Caekenberghe sven at stfx.eu
Thu Jan 10 22:58:42 UTC 2013


Hi Ken,

On 10 Jan 2013, at 21:48, Ken Treis <ken at miriamtech.com> wrote:

> I thought I'd try to make the Zinc server adaptor use WAComboResponse (like the Comanche adaptor does), but I'm running into some issues.
> 
> 1. I need a handle on the underlying stream, but this is unknown to the ZnRequest once it's been read. ZnServer knows it, and the entity (if any) knows it if it's been read in a streaming fashion, but otherwise the stream isn't available to the Seaside server adaptor.
> 
> 2. The Zinc server expects to write a response every time -- it doesn't have the #isCommitted plumbing that Comanche does for checking whether a response has already been committed. 
> 
> I was first tempted to modify Zinc itself (in blatant violation of the open/closed principle), but perhaps it'd be better to make a new subclass of ZnServer that'd handle these issues natively. The only downside: you'd lose the ability to plug your own ZnServer into your Seaside adaptor. Maybe that's OK, if everybody's basically using the "managing multi-threaded" approach anyway. Do we really need the flexibility of a pluggable threading approach?
> 
> Any thoughts/direction would be greatly appreciated.

It is great that you are interested in this subject. From your analysis, I feel that you understand the subject quite well, so it would be cool if you could contribute. I will do my best to help.

Both of your conclusions are correct, but there are options within the current Zn architecture that could help.

Have a look at #useConnection: (it was added for and is used by Zinc-WebSocket) it allows a response to do something with the raw stream after the response was written. Of course, you have to subclass ZnResponse for that, like ZnWebSocketResponse does. The final closing is controlled by #wantsConnectionClose. Once you have a subclass you could customize #writeOn: to work differently: just write the header, check the state, and so on. After this partial write, you can use the raw connection and write to it at will. You will probably need a ZnChunkedWriteStream (the inverse of the existing ZnChunkedReadStream), unless something similar (to write chunks) is already in Seaside - that shouldn't be very hard. [ I justed looked, there is #nextChunkPut: ]

You will also have to subclass ZnZincServerAdaptor and change #responseFrom: to use your ZnResponse subclass as appropriate.

Please go ahead and try to build a proof of concept. I think /hope it is possible with the current design. Use cases like this can only make Zn better.

HTH,

Sven

PS: Also make sure you are using the bleedingEdge of Zinc, as there have been quite some changes lately, including to the Seaside adaptor.


--
Sven Van Caekenberghe
http://stfx.eu
Smalltalk is the Red Pill



More information about the seaside-dev mailing list