packages feed

http-streams 0.5.0.2 → 0.6.0.0

raw patch · 5 files changed

+37/−22 lines, 5 filesdep ~io-streamsdep ~openssl-streamsPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: io-streams, openssl-streams

API changes (from Hackage documentation)

- Network.Http.Client: setContentLength :: Int -> RequestBuilder ()
+ Network.Http.Client: setContentLength :: Int64 -> RequestBuilder ()

Files

http-streams.cabal view
@@ -1,6 +1,6 @@ cabal-version:       >= 1.10 name:                http-streams-version:             0.5.0.2+version:             0.6.0.0 synopsis:            An HTTP client using io-streams description:  /Overview/@@ -19,7 +19,7 @@ maintainer:          Andrew Cowie <andrew@operationaldynamics.com> copyright:           © 2012-2013 Operational Dynamics Consulting, Pty Ltd and Others category:            Web-tested-with:         GHC == 7.4+tested-with:         GHC == 7.6 stability:           experimental homepage:            http://research.operationaldynamics.com/projects/http-streams/ bug-reports:         https://github.com/afcowie/http-streams/issues@@ -35,9 +35,9 @@                      blaze-builder,                      bytestring,                      case-insensitive,-                     io-streams >= 1.0.2.2 && <1.1,+                     io-streams >= 1.1 && <1.2,                      HsOpenSSL,-                     openssl-streams >= 1.0 && <1.1,+                     openssl-streams >= 1.1 && <1.2,                      mtl,                      transformers,                      network,@@ -88,7 +88,7 @@                      mtl,                      transformers,                      network,-                     openssl-streams >= 1.0 && <1.1,+                     openssl-streams,                      snap-core       >= 0.9    && < 1.0,                      snap-server     >= 0.9    && < 1.0,                      system-fileio   >= 0.3.10 && < 0.4,
src/Network/Http/RequestBuilder.hs view
@@ -38,6 +38,7 @@ import qualified Data.ByteString.Base64 as BS64 import Data.ByteString.Char8 () import qualified Data.ByteString.Char8 as S+import Data.Int (Int64) import Data.List (intersperse) import Data.Monoid (mconcat) @@ -270,7 +271,7 @@ -- writes precisely that many bytes. -- ---setContentLength :: Int -> RequestBuilder ()+setContentLength :: Int64 -> RequestBuilder () setContentLength n = do     deleteHeader "Transfer-Encoding"     setHeader "Content-Length" (S.pack $ show n)
src/Network/Http/ResponseParser.hs view
@@ -56,7 +56,7 @@     bytes into our InputStream at an appropriate intermediate size. -} __BITE_SIZE__ :: Int-__BITE_SIZE__ = (32::Int) * (1024::Int)+__BITE_SIZE__ = 32 * 1024   {-@@ -82,16 +82,17 @@                         else Identity             Nothing -> Identity -    let n  = case lookupHeader h "Content-Length" of-            Just x' -> readDecimal x' :: Int-            Nothing -> 0+    let nm = case lookupHeader h "Content-Length" of+            Just x' -> Just (readDecimal x' :: Int64)+            Nothing -> Nothing +     return Response {         pStatusCode = sc,         pStatusMsg = sm,         pTransferEncoding = te,         pContentEncoding = ce,-        pContentLength = n,+        pContentLength = nm,         pHeaders = h     } @@ -119,7 +120,9 @@ readResponseBody p i1 = do      i2 <- case t of-        None        -> readFixedLengthBody i1 n+        None        -> case l of+                        Just n  -> readFixedLengthBody i1 n+                        Nothing -> readUnlimitedBody i1         Chunked     -> readChunkedBody i1      i3 <- case c of@@ -131,15 +134,15 @@   where     t = pTransferEncoding p     c = pContentEncoding p-    n = pContentLength p+    l = pContentLength p -readDecimal :: (Enum a, Num a, Bits a) => ByteString -> a+readDecimal :: (Enum α, Num α, Bits α) => ByteString -> α readDecimal = S.foldl' f 0   where     f !cnt !i = cnt * 10 + digitToInt i      {-# INLINE digitToInt #-}-    digitToInt :: (Enum a, Num a, Bits a) => Char -> a+    digitToInt :: (Enum α, Num α, Bits α) => Char -> α     digitToInt c | c >= '0' && c <= '9' = toEnum $! ord c - ord '0'                  | otherwise = error $ "'" ++ [c] ++ "' is not an ascii digit" {-# INLINE readDecimal #-}@@ -241,10 +244,20 @@     after the requested number of bytes. Otherwise, code handling     responses waits on more input until an HTTP timeout occurs. -}-readFixedLengthBody :: InputStream ByteString -> Int -> IO (InputStream ByteString)+readFixedLengthBody :: InputStream ByteString -> Int64 -> IO (InputStream ByteString) readFixedLengthBody i1 n = do-    i2 <- Streams.takeBytes (fromIntegral n :: Int64) i1+    i2 <- Streams.takeBytes n i1     return i2++{-+    On the other hand, there is the (predominently HTTP/1.0) case+    where there is no content length sent and no chunking, with the+    result that only the connection closing marks the end of the+    response body.+-}+readUnlimitedBody :: InputStream ByteString -> IO (InputStream ByteString)+readUnlimitedBody i1 = do+    return i1   ---------------------------------------------------------------------
src/Network/Http/Types.hs view
@@ -55,6 +55,7 @@ import Data.CaseInsensitive (CI, mk, original) import Data.HashMap.Strict (HashMap, delete, empty, foldrWithKey, insert,                             insertWith, lookup)+import Data.Int (Int64) import Data.List (foldl') import Data.Monoid (mconcat, mempty) import Data.Typeable (Typeable)@@ -115,7 +116,7 @@ data Request     = Request {         qMethod  :: !Method,-        qHost    ::  Maybe ByteString,+        qHost    :: !(Maybe ByteString),         qPath    :: !ByteString,         qBody    :: !EntityBody,         qExpect  :: !ExpectMode,@@ -127,7 +128,7 @@         S.unpack $ S.filter (/= '\r') $ Builder.toByteString $ composeRequestBytes q "<default>"  -data EntityBody = Empty | Chunking | Static Int+data EntityBody = Empty | Chunking | Static Int64  data ExpectMode = Normal | Continue @@ -211,7 +212,7 @@         pStatusMsg        :: !ByteString,         pTransferEncoding :: !TransferEncoding,         pContentEncoding  :: !ContentEncoding,-        pContentLength    :: !Int,+        pContentLength    :: !(Maybe Int64),         pHeaders          :: !Headers     } 
tests/Check.hs view
@@ -16,10 +16,10 @@ import OpenSSL (withOpenSSL) import Test.Hspec (hspec) -import TestServer (runTestServer)+import MockServer (runMockServer) import TestSuite (suite)  main :: IO () main = withOpenSSL $ do-    runTestServer+    runMockServer     hspec suite