http-client 0.5.10 → 0.5.11
raw patch · 6 files changed
+47/−23 lines, 6 filesdep +memorydep −base64-bytestring
Dependencies added: memory
Dependencies removed: base64-bytestring
Files
- ChangeLog.md +4/−0
- Network/HTTP/Client/Request.hs +11/−5
- Network/HTTP/Client/Types.hs +1/−2
- Network/HTTP/Proxy.hs +1/−0
- http-client.cabal +5/−4
- test-nonet/Network/HTTP/ClientSpec.hs +25/−12
ChangeLog.md view
@@ -1,3 +1,7 @@+## 0.5.11++* Replaced `base64-bytestring` dependency with `memory`.+ ## 0.5.10 * New function to partial escape query strings
Network/HTTP/Client/Request.hs view
@@ -56,7 +56,7 @@ import Control.Exception (throw, throwIO, IOException) import qualified Control.Exception as E import qualified Data.CaseInsensitive as CI-import qualified Data.ByteString.Base64 as B64+import qualified Data.ByteArray.Encoding as BAE import Network.HTTP.Client.Body import Network.HTTP.Client.Types@@ -266,6 +266,14 @@ browserDecompress :: S.ByteString -> Bool browserDecompress = (/= "application/x-tar") +-- | Build a basic-auth header value+buildBasicAuth ::+ S8.ByteString -- ^ Username+ -> S8.ByteString -- ^ Password+ -> S8.ByteString+buildBasicAuth user passwd =+ S8.append "Basic " (BAE.convertToBase BAE.Base64 (S8.concat [ user, ":", passwd ]))+ -- | Add a Basic Auth header (with the specified user name and password) to the -- given Request. Ignore error handling: --@@ -280,8 +288,7 @@ applyBasicAuth user passwd req = req { requestHeaders = authHeader : requestHeaders req } where- authHeader = (CI.mk "Authorization", basic)- basic = S8.append "Basic " (B64.encode $ S8.concat [ user, ":", passwd ])+ authHeader = (CI.mk "Authorization", buildBasicAuth user passwd) -- | Add a proxy to the Request so that the Request when executed will use -- the provided proxy.@@ -302,8 +309,7 @@ applyBasicProxyAuth user passwd req = req { requestHeaders = authHeader : requestHeaders req } where- authHeader = (CI.mk "Proxy-Authorization", basic)- basic = S8.append "Basic " (B64.encode $ S8.concat [ user , ":", passwd ])+ authHeader = (CI.mk "Proxy-Authorization", buildBasicAuth user passwd) -- | Add url-encoded parameters to the 'Request'. --
Network/HTTP/Client/Types.hs view
@@ -59,7 +59,6 @@ import Data.Streaming.Zlib (ZlibException) import Data.CaseInsensitive as CI import Data.KeyedPool (KeyedPool)-import Control.Applicative((<$>)) -- | An @IO@ action that represents an incoming response body coming from the -- server. Data provided by this action has already been gunzipped and@@ -582,7 +581,7 @@ ] redactSensitiveHeader :: Header -> Header-redactSensitiveHeader ("Authorization", value) = ("Authorization", "<REDACTED>")+redactSensitiveHeader ("Authorization", _) = ("Authorization", "<REDACTED>") redactSensitiveHeader h = h -- | A simple representation of the HTTP response.
Network/HTTP/Proxy.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE FlexibleContexts #-} {- Copyright (c) 2002, Warrick Gray
http-client.cabal view
@@ -1,5 +1,5 @@ name: http-client-version: 0.5.10+version: 0.5.11 synopsis: An HTTP client engine 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@@ -49,7 +49,7 @@ , transformers , deepseq >= 1.3 && <1.5 , case-insensitive >= 1.0- , base64-bytestring >= 1.0 && <1.1+ , memory >= 0.7 , cookie , exceptions >= 0.4 , array@@ -91,7 +91,6 @@ , transformers , deepseq , case-insensitive- , base64-bytestring , zlib , async , streaming-commons >= 0.1.1@@ -102,6 +101,9 @@ type: exitcode-stdio-1.0 hs-source-dirs: test-nonet default-language: Haskell2010+ ghc-options: -threaded+ if os(windows)+ cpp-options: -DWINDOWS other-modules: Network.HTTP.ClientSpec Network.HTTP.Client.ResponseSpec Network.HTTP.Client.BodySpec@@ -124,7 +126,6 @@ , transformers , deepseq , case-insensitive- , base64-bytestring , zlib , async , streaming-commons >= 0.1.1
test-nonet/Network/HTTP/ClientSpec.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} module Network.HTTP.ClientSpec where@@ -21,6 +22,14 @@ import Data.IORef import System.Mem (performGC) +-- See: https://github.com/snoyberg/http-client/issues/111#issuecomment-366526660+notWindows :: Monad m => m () -> m ()+#ifdef WINDOWS+notWindows _ = return ()+#else+notWindows x = x+#endif+ main :: IO () main = hspec spec @@ -57,7 +66,9 @@ Async.race_ (silentIOError $ forever (N.appRead ad)) (silentIOError $ N.appWrite ad "HTTP/1.1 301 Redirect\r\nLocation: /\r\nConnection: close\r\n\r\nhello")- N.appCloseConnection ad+ case N.appRawSocket ad of+ Nothing -> error "appRawSocket failed"+ Just s -> NS.shutdown s NS.ShutdownSend bad100Server :: Bool -- ^ include extra headers? -> (Int -> IO a) -> IO a@@ -110,12 +121,14 @@ lengthZeroAndChunkZero = serveWith "HTTP/1.1 200 OK\r\ncontent-length: 0\r\ntransfer-encoding: chunked\r\n\r\n0\r\n\r\n" serveWith :: S.ByteString -> (Int -> IO a) -> IO a-serveWith resp inner = bracket- (N.bindRandomPortTCP "*4")- (NS.close . snd)- $ \(port, lsocket) -> withAsync- (N.runTCPServer (N.serverSettingsTCPSocket lsocket) app)- (const $ inner port)+serveWith resp inner = do+ (port, lsocket) <- (N.bindRandomPortTCP "*4")+ res <- Async.race+ (N.runTCPServer (N.serverSettingsTCPSocket lsocket) app)+ (inner port)+ case res of+ Left () -> error $ "serveWith: got Left"+ Right x -> return x where app ad = silentIOError $ do let readHeaders front = do@@ -185,28 +198,28 @@ test False test True - it "early close on a 413" $ earlyClose413 $ \port' -> do+ notWindows $ it "early close on a 413" $ earlyClose413 $ \port' -> do man <- newManager defaultManagerSettings res <- getChunkedResponse port' man responseBody res `shouldBe` "goodbye" responseStatus res `shouldBe` status413 - it "length zero and chunking zero #108" $ lengthZeroAndChunkZero $ \port' -> do+ notWindows $ it "length zero and chunking zero #108" $ lengthZeroAndChunkZero $ \port' -> do man <- newManager defaultManagerSettings res <- getChunkedResponse port' man responseBody res `shouldBe` "" - it "length zero and chunking" $ lengthZeroAndChunked $ \port' -> do+ notWindows $ it "length zero and chunking" $ lengthZeroAndChunked $ \port' -> do man <- newManager defaultManagerSettings res <- getChunkedResponse port' man responseBody res `shouldBe` "Wikipedia in\r\n\r\nchunks." - it "length and chunking" $ lengthAndChunked $ \port' -> do+ notWindows $ it "length and chunking" $ lengthAndChunked $ \port' -> do man <- newManager defaultManagerSettings res <- getChunkedResponse port' man responseBody res `shouldBe` "Wikipedia in\r\n\r\nchunks." - it "withResponseHistory and redirect" $ redirectCloseServer $ \port -> do+ notWindows $ it "withResponseHistory and redirect" $ redirectCloseServer $ \port -> do -- see https://github.com/snoyberg/http-client/issues/169 req' <- parseUrlThrow $ "http://127.0.0.1:" ++ show port let req = req' {redirectCount = 1}