@@ -17,6 +17,8 @@ import Criterion.Main
1717-- $setup
1818-- >>> :set -XOverloadedStrings
1919
20+----------------------------------------------------------------
21+
2022main :: IO ()
2123main = do
2224 let requestLine1 = "GET http://www.example.com HTTP/1.1"
@@ -35,10 +37,11 @@ main = do
3537----------------------------------------------------------------
3638
3739parseRequestLine2 :: ByteString
38− -> IO (H.Method
39− ,ByteString -- Path
40− ,ByteString -- Query
41− ,H.HttpVersion)
40+ -> IO (H.Method
41+ ,ByteString -- Path
42+ ,ByteString -- Query
43+ ,H.HttpVersion)
44+
4245parseRequestLine2 requestLine = undefined
4346
4447----------------------------------------------------------------
@@ -49,15 +52,15 @@ parseRequestLine2 requestLine = undefined
4952-- ("GET","/","",HTTP/1.1)
5053-- >>> parseRequestLine1 "POST /cgi/search.cgi?key=foo HTTP/1.0"
5154-- ("POST","/cgi/search.cgi","?key=foo",HTTP/1.0)
52−-- >>> parseRequestLine1 "GET /NoHTTPVersion"
53−-- *** Exception: BadFirstLine "GET /NoHTTPVersion"
55+-- >>> parseRequestLine1 "GET "
56+-- *** Exception: BadFirstLine "GET "
5457-- >>> parseRequestLine1 "GET /NotHTTP UNKNOWN/1.1"
5558-- *** Exception: NonHttp
5659parseRequestLine1 :: ByteString
57− -> IO (H.Method
58− ,ByteString -- Path
59− ,ByteString -- Query
60− ,H.HttpVersion)
60+ -> IO (H.Method
61+ ,ByteString -- Path
62+ ,ByteString -- Query
63+ ,H.HttpVersion)
6164parseRequestLine1 requestLine = do
6265 let (!method,!rest) = S.breakByte 32 requestLine -- ' '
6366 (!pathQuery,!httpVer') = S.breakByte 32 (S.drop 1 rest) -- ' '
@@ -73,6 +76,16 @@ parseRequestLine1 requestLine = do
7376
7477----------------------------------------------------------------
7578
79+-- |
80+--
81+-- >>> parseRequestLine0 "GET / HTTP/1.1"
82+-- ("GET","/","",HTTP/1.1)
83+-- >>> parseRequestLine0 "POST /cgi/search.cgi?key=foo HTTP/1.0"
84+-- ("POST","/cgi/search.cgi","?key=foo",HTTP/1.0)
85+-- >>> parseRequestLine0 "GET "
86+-- *** Exception: BadFirstLine "GET "
87+-- >>> parseRequestLine0 "GET /NotHTTP UNKNOWN/1.1"
88+-- *** Exception: NonHttp
7689parseRequestLine0 :: ByteString
7790 -> IO (H.Method
7891 ,ByteString -- Path