http-kit 0.2.0 → 0.2.1
raw patch · 6 files changed
+29/−3 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Network.HTTP.Toolkit: simpleResponse :: (ByteString -> IO ()) -> Status -> [Header] -> ByteString -> IO ()
+ Network.HTTP.Toolkit.Response: simpleResponse :: (ByteString -> IO ()) -> Status -> [Header] -> ByteString -> IO ()
Files
- http-kit.cabal +1/−1
- src/Network/HTTP/Toolkit.hs +1/−0
- src/Network/HTTP/Toolkit/Body.hs +3/−0
- src/Network/HTTP/Toolkit/Header.hs +4/−1
- src/Network/HTTP/Toolkit/Request.hs +4/−1
- src/Network/HTTP/Toolkit/Response.hs +16/−0
http-kit.cabal view
@@ -1,5 +1,5 @@ name: http-kit-version: 0.2.0+version: 0.2.1 synopsis: A low-level HTTP library description: A low-level HTTP library that can be used to build more sophisticated applications on top of it.
src/Network/HTTP/Toolkit.hs view
@@ -15,6 +15,7 @@ , readResponseWithLimit , readResponse , sendResponse+, simpleResponse -- * Handling message bodies , BodyReader
src/Network/HTTP/Toolkit/Body.hs view
@@ -101,6 +101,9 @@ -- | Read input from provided `BodyReader` and wirte it to provided sink until -- all input has been consumed.+--+-- /Note:/ The first argument to this function is used to send the data. For+-- space efficiency it may be called multiple times. sendBody :: (ByteString -> IO ()) -> BodyReader -> IO () sendBody send body = while (not . B.null) body send
src/Network/HTTP/Toolkit/Header.hs view
@@ -110,7 +110,10 @@ | otherwise = bs -- | Send given start-line and message headers.-sendHeader :: (ByteString -> IO()) -> ByteString -> [Header] -> IO ()+--+-- /Note:/ The first argument to this function is used to send the data. For+-- space efficiency it may be called multiple times.+sendHeader :: (ByteString -> IO ()) -> ByteString -> [Header] -> IO () sendHeader send startLine headers = do send startLine send "\r\n"
src/Network/HTTP/Toolkit/Request.hs view
@@ -71,7 +71,10 @@ formatRequestLine method path = B.unwords [method, path, "HTTP/1.1"] -- | Send an HTTP request.-sendRequest :: (ByteString -> IO()) -> Request BodyReader -> IO ()+--+-- /Note:/ The first argument to this function is used to send the data. For+-- space efficiency it may be called multiple times.+sendRequest :: (ByteString -> IO ()) -> Request BodyReader -> IO () sendRequest send (Request method path headers body) = do sendHeader send (formatRequestLine method path) headers sendBody send body
src/Network/HTTP/Toolkit/Response.hs view
@@ -5,6 +5,7 @@ , readResponseWithLimit , parseStatusLine +, simpleResponse , sendResponse , formatStatusLine @@ -81,7 +82,22 @@ formatStatusLine :: Status -> ByteString formatStatusLine status = B.concat ["HTTP/1.1 ", B.pack $ show (statusCode status), " ", statusMessage status] +-- | Send a simple HTTP response. The provided `ByteString` is used as the+-- message body. A suitable @Content-Length@ header is added to the specified+-- list of headers.+--+-- /Note:/ The first argument to this function is used to send the data. For+-- space efficiency it may be called multiple times.+simpleResponse :: (ByteString -> IO ()) -> Status -> [Header] -> ByteString -> IO ()+simpleResponse send status headers_ body = do+ fromByteString body >>= sendResponse send . Response status headers+ where+ headers = ("Content-Length", B.pack . show . B.length $ body) : headers_+ -- | Send an HTTP response.+--+-- /Note:/ The first argument to this function is used to send the data. For+-- space efficiency it may be called multiple times. sendResponse :: (ByteString -> IO ()) -> (Response BodyReader) -> IO () sendResponse send (Response status headers body) = do sendHeader send (formatStatusLine status) headers