[web-devel] Re: Lazy simpleHTTP

Henning Thielemann lemming at henning-thielemann.de
Fri Nov 28 18:26:18 EST 2008


On Thu, 27 Nov 2008, Henning Thielemann wrote:

> I have HTTP-3001.0.4 and I like to check the HTTP response headers before 
> downloading the entire document.

I have tried to solve this on my own. I have written a wrapper to any 
stream type. It first reads the entire document lazily into a string and 
then ships its contents when readBlock or readLine is called. However, the 
program blocks on 'close' now and I don't know why. (See 
LazyStream.example)

When looking at Network.HTTP.sendHTTP I wonder whether it is a good idea, 
that sendHTTP closes the stream automatically when it finishs (and also 
when an exception is raised). In general I think it is good, when the one 
who opens a stream is also responsible for closing it.
  For a lazy stream, the current implementation of sendHTTP would fail, 
since when sendHTTP quits, the data is still not read, and when some 
processes the HTTP response, data will be lazily read from a closed 
stream.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LazyStream.hs
Type: text/x-haskell
Size: 2927 bytes
Desc: 
Url : http://www.haskell.org/pipermail/web-devel/attachments/20081129/43421518/LazyStream-0001.bin


More information about the web-devel mailing list