[web-devel] On the state of Haskell web frameworks

Gregory Collins greg at gregorycollins.net
Tue Mar 16 02:03:05 EDT 2010

Curt Sampson <cjs at starling-software.com> writes:

> I think that the ideal "interface" is something that gives you a web
> request extremly close to exactly how it came in to the web server, and
> let you send what is essentially a raw response. This allows developers
> to work with that directly, if they chose, or use a library interfaces
> with that, does whatever parsing and other things it cares to, and
> presents some other interface on the other side of that.
> If the world could work in such a way we'd probably have several
> different libraries to provide varoius interfaces, including a CGI-like
> interface, and the world would be a happy place.
> Unfortunately, the world doesn't actually work that way. Interfaces (and
> their associated protocols) such as CGI, SCGI, FastCGI and AJP don't
> present the raw web request; instead they do a large amount of parsing
> and modification of the request; exactly how this is done varies not
> only with the implementation but with the web server configuration.

I think I agree with you completely. The question is: where do you draw
the lines? You probably want transfer-encodings handled for you, but
what about POST data? In Snap right now we detect requests with mime
type "application/x-www-form-urlencoded" and parse them for you -- IMO
why on earth would you want anything else? But I'm sure there are people
who wouldn't be comfortable with that behaviour.

Another example: we treat responses differently based on whether you
explicitly set a content length or not. If the connection is HTTP/1.0,
and you don't set a content length, we have to set "Connection: close"
in the response headers and close the socket when we're finished sending
the response, because otherwise the client has no way of knowing when
the stream ends. If the connection is HTTP/1.1 and there's no content
length, we set "Transfer-encoding: chunked" and encode the response body
accordingly. If there is a content-length, we use it, because it's a few
bytes cheaper.

How much of that sort of logic goes into the interface layer? What
guarantees does an application written on (for example) the WAI
interface receive about what the web server will or will not touch?

Gregory Collins <greg at gregorycollins.net>

More information about the web-devel mailing list