[web-devel] Upcoming WAI changes

Michael Snoyman michael at snoyman.com
Tue Mar 15 21:24:46 CET 2011

Hi all,

I wanted to bring up for discussion some planned changes to the WAI.
You can see what I'm proposing on Github[1]. The first thing you might
notice is that the Network.Wai module is significantly smaller than it
used to be. This is because a number of the constants and data types
previously defined in WAI are now provided by the http-types[2]
package. Besides the smaller code base, the following changes are also

* HttpVersion is no longer a ByteString; instead, it is a datatype
with two Ints. So HTTP/1.1 becomes HttpVersion 1 1.

* pathInfo is renamed to pathInfoRaw, and the new pathInfo is a [Text]
value. This represents the *parsed* path info. For example:

    GET /foo/bar HTTP/1.0


    ["foo", "bar"]

By including this in the definition of WAI, it's simpler to provide
sub-apps. For example:

masterApp req =
    case pathInfo req of
        "site1":rest -> site1 $ req { pathInfo = req }

* Similarly, queryString becomes queryStringRaw and queryString is now
a [(ByteString, Maybe ByteString)]. This allows the query string to be
processed once and the value shared amongst all middlewares and
applications. If you are wondering why we use ByteString and not Text,
it is because the query string can have any arbitrary encoding. The
path info, on the other hand, is (basically) required to be UTF-8.

* In place of CIByteString, we now have CIAscii. Besides the slightly
nicer name, this is now taking advantage of the newly written ascii[3]
and case-insensitive[4] packages.

* Header values are given as Ascii values instead of ByteStrings.

If anyone has concerns about these changes, please raise them. I'd
rather get all the complaints out in the open before releasing a new


[1] https://github.com/snoyberg/wai/blob/master/Network/Wai.hs
[2] http://hackage.haskell.org/package/http-types
[3] http://hackage.haskell.org/package/ascii
[4] http://hackage.haskell.org/package/case-insensitive

More information about the web-devel mailing list