context-http-client 0.2.0.0 → 0.2.0.1
raw patch · 4 files changed
+26/−23 lines, 4 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- context-http-client.cabal +2/−2
- package.yaml +2/−2
- test-suite/Test/Network/HTTP/Client/ContextSpec.hs +18/−19
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Change log +## 0.2.0.1++* Backwards compatibility with GHC 8.4 (@pbrisbin)+ ## 0.2.0.0 * Dependency bump: `context-0.2.0.0`
context-http-client.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: context-http-client-version: 0.2.0.0+version: 0.2.0.1 synopsis: Modify HTTP requests/responses using context description: Modify outgoing HTTP requests and incoming HTTP responses using context. category: Web@@ -37,7 +37,7 @@ library ghc-options: -Wall -fwarn-tabs -Wincomplete-uni-patterns -Wredundant-constraints build-depends:- base >=4.12 && <5+ base >=4.11.1.0 && <5 , context >=0.2.0.0 && <0.3 , http-client >=0.5.13.1 && <0.8 default-language: Haskell2010
package.yaml view
@@ -1,5 +1,5 @@ name: context-http-client-version: '0.2.0.0'+version: '0.2.0.1' github: "jship/context/context-http-client" license: MIT license-file: LICENSE.md@@ -25,7 +25,7 @@ library: dependencies:- - base >=4.12 && <5+ - base >=4.11.1.0 && <5 - context >=0.2.0.0 && <0.3 - http-client >=0.5.13.1 && <0.8 source-dirs: library
test-suite/Test/Network/HTTP/Client/ContextSpec.hs view
@@ -1,6 +1,5 @@ {-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} -{-# LANGUAGE BlockArguments #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-}@@ -29,14 +28,14 @@ spec :: Spec spec = do- describe "modifyRequestsWithContext" do- it "concurrent test" do+ describe "modifyRequestsWithContext" $ do+ it "concurrent test" $ do numberQueue <- TQueue.newTQueueIO @Int let app = \request sendResponse -> do let headers = Wai.requestHeaders request let [number] = fmap (read . ByteString.Char8.unpack . snd)- $ flip filter headers \(headerName, _) ->+ $ flip filter headers $ \(headerName, _) -> "number" == CI.foldedCase headerName STM.atomically $ TQueue.writeTQueue numberQueue number@@ -60,11 +59,11 @@ { HTTP.Client.requestHeaders = ("number", ByteString.Char8.pack $ show context) : flip filter (HTTP.Client.requestHeaders request)- \(headerName, _) ->- "number" /= CI.foldedCase headerName+ (\(headerName, _) ->+ "number" /= CI.foldedCase headerName) } - Context.withEmptyStore \contextStore -> do+ Context.withEmptyStore $ \contextStore -> do manager <- HTTP.Client.newManager $ HTTP.Client.Context.modifyRequestsWithContext@@ -73,18 +72,18 @@ HTTP.Client.defaultManagerSettings -- Spin up a test server for the 'app' defined above.- Warp.testWithApplication (pure app) \port -> do+ Warp.testWithApplication (pure app) $ \port -> do request <- HTTP.Client.parseRequest $ "http://localhost:" <> show port <> "/abc/def" -- Spin up 10 threads that each make 3 http requests into the test -- server.- Async.forConcurrently_ [0 :: Int .. 9] \i -> do- Foldable.for_ [1..3] \j -> do+ Async.forConcurrently_ [0 :: Int .. 9] $ \i -> do+ Foldable.for_ [1..3] $ \j -> do -- By using a context here, behind the scenes the manager will also -- have access to this context as it will send on this same thread.- Context.use contextStore (3 * i + j) do+ Context.use contextStore (3 * i + j) $ do response <- HTTP.Client.httpLbs request manager HTTP.Types.statusCode (HTTP.Client.responseStatus response) `shouldBe` 200@@ -94,8 +93,8 @@ numbers <- STM.atomically $ TQueue.flushTQueue numberQueue List.sort numbers `shouldBe` [1..30] - describe "modifyResponsesWithContext" do- it "concurrent test" do+ describe "modifyResponsesWithContext" $ do+ it "concurrent test" $ do let app = \_request sendResponse -> do sendResponse $ Wai.responseLBS@@ -121,7 +120,7 @@ : HTTP.Client.responseHeaders response } - Context.withEmptyStore \contextStore -> do+ Context.withEmptyStore $ \contextStore -> do manager <- HTTP.Client.newManager $ HTTP.Client.Context.modifyResponsesWithContext@@ -130,16 +129,16 @@ HTTP.Client.defaultManagerSettings -- Spin up a test server for the 'app' defined above.- Warp.testWithApplication (pure app) \port -> do+ Warp.testWithApplication (pure app) $ \port -> do request <- HTTP.Client.parseRequest $ "http://localhost:" <> show port <> "/abc/def" -- Spin up 10 threads that each make 3 http requests into the test -- server.- Async.forConcurrently_ [0 :: Int .. 9] \i -> do- Foldable.for_ [1..3] \j -> do- Context.use contextStore (3 * i + j) do+ Async.forConcurrently_ [0 :: Int .. 9] $ \i -> do+ Foldable.for_ [1..3] $ \j -> do+ Context.use contextStore (3 * i + j) $ do response <- HTTP.Client.httpLbs request manager HTTP.Types.statusCode (HTTP.Client.responseStatus response) `shouldBe` 200@@ -149,7 +148,7 @@ let headers = HTTP.Client.responseHeaders response let [number] = fmap (read . ByteString.Char8.unpack . snd)- $ flip filter headers \(headerName, _) ->+ $ flip filter headers $ \(headerName, _) -> "number" == CI.foldedCase headerName number `shouldBe` 3 * i + j