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

Curt Sampson cjs at starling-software.com
Tue Mar 16 01:25:23 EDT 2010


On 2010-03-16 01:04 -0400 (Tue), Gregory Collins wrote:

> And there IS a lot of interest in and support of the idea of
> standardizing a web application interface for haskell...

Speaking as someone who spent ten years doing more web applications than
he cares to think about, and having written a web application framework,
I'd like to make a couple of points about this.

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.

Some of the things passed via this protocol, such as SCRIPT_NAME and
PATH_TRANSLATED, often don't make sense in the context of a single
application running behind a web server. Others, such as PATH_INFO,
will have different values for the same URL depending on the web server
configuration. Other information is missing entirely. For example, most
of these protocols don't even give you the URL that was used; if you
want it you have to try to reconsruct it using your best guess about the
web server configuration.

Unfortunately, I don't really have a good solution to this. The best I
can come up with is to have a simple, standard inteface that delivers
essentially the raw request for use with web servers written in Haskell
and suggest that anybody who wants to use a different web server just
use it as a proxy. It would be possible to provide libraries that try to
take, e.g., a FastCGI request and turn it back into the raw request, but
this can't be done very reliably.

cjs
-- 
Curt Sampson         <cjs at cynic.net>         +81 90 7737 2974
             http://www.starling-software.com
The power of accurate observation is commonly called cynicism
by those who have not got it.    --George Bernard Shaw


More information about the web-devel mailing list