packages feed

http-client 0.4.30 → 0.4.31

raw patch · 4 files changed

+25/−10 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Network.HTTP.Client: WrongRequestBodyStreamSize :: Word64 -> Word64 -> HttpException
+ Network.HTTP.Client.Internal: WrongRequestBodyStreamSize :: Word64 -> Word64 -> HttpException

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+## 0.4.31++* Added length validation for RequestBodyStream [#205](https://github.com/snoyberg/http-client/pull/205)+ ## 0.4.30  * Initial implementation of [#193](https://github.com/snoyberg/http-client/issues/193)
Network/HTTP/Client/Request.hs view
@@ -3,6 +3,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE CPP #-} {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE BangPatterns #-}  {-# OPTIONS_GHC -fno-warn-orphans #-} @@ -32,7 +33,7 @@     ) where  import Data.Int (Int64)-import Data.Maybe (fromMaybe, isJust)+import Data.Maybe (fromMaybe, isJust, isNothing) import Data.Monoid (mempty, mappend) import Data.String (IsString(..)) import Data.Char (toLower)@@ -405,7 +406,7 @@     toTriple (RequestBodyStream len stream) = do         -- See https://github.com/snoyberg/http-client/issues/74 for usage         -- of flush here.-        let body = writeStream False stream+        let body = writeStream (Just . fromIntegral $ len) stream             -- Don't check for a bad send on the headers themselves.             -- Ideally, we'd do the same thing for the other request body             -- types, but it would also introduce a performance hit since@@ -413,28 +414,32 @@             now  = flushHeaders (Just len) >> checkBadSend body         return (Just len, now, body)     toTriple (RequestBodyStreamChunked stream) = do-        let body = writeStream True stream+        let body = writeStream Nothing stream             now  = flushHeaders Nothing >> checkBadSend body         return (Nothing, now, body)     toTriple (RequestBodyIO mbody) = mbody >>= toTriple -    writeStream isChunked withStream =-        withStream loop+    writeStream mlen withStream =+        withStream (loop 0)        where-        loop stream = do+        loop !n stream = do             bs <- stream             if S.null bs-                then when isChunked $ connectionWrite "0\r\n\r\n"+                then case mlen of +                    -- If stream is chunked, no length argument+                    Nothing -> connectionWrite "0\r\n\r\n"+                    -- Not chunked - validate length argument+                    Just len -> unless (len == n) $ throwIO $ WrongRequestBodyStreamSize (fromIntegral len) (fromIntegral n)                 else do                     connectionWrite $-                        if isChunked+                        if (isNothing mlen) -- Chunked                             then S.concat                                 [ S8.pack $ showHex (S.length bs) "\r\n"                                 , bs                                 , "\r\n"                                 ]                             else bs-                    loop stream+                    loop (n + (S.length bs)) stream       hh
Network/HTTP/Client/Types.hs view
@@ -119,6 +119,12 @@                    | NoResponseDataReceived                    | TlsException SomeException                    | TlsNotSupported+                   | WrongRequestBodyStreamSize Word64 Word64+                   -- ^ The request body provided did not match the expected size.+                   --+                   -- Provides the expected and actual size.+                   --+                   -- @since 0.4.31                    | ResponseBodyTooShort Word64 Word64                    -- ^ Expected size/actual size.                    --
http-client.cabal view
@@ -1,5 +1,5 @@ name:                http-client-version:             0.4.30+version:             0.4.31 synopsis:            An HTTP client engine, intended as a base layer for more user-friendly packages. description:         Hackage documentation generation is not reliable. For up to date documentation, please see: <http://www.stackage.org/package/http-client>. homepage:            https://github.com/snoyberg/http-client