http-client 0.7.5 → 0.7.6
raw patch · 5 files changed
+35/−1 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Network.HTTP.Client: applyBearerAuth :: ByteString -> Request -> Request
+ Network.HTTP.Client.Internal: applyBearerAuth :: ByteString -> Request -> Request
Files
- ChangeLog.md +4/−0
- Network/HTTP/Client.hs +1/−0
- Network/HTTP/Client/Request.hs +17/−0
- http-client.cabal +1/−1
- test/Network/HTTP/ClientSpec.hs +12/−0
ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for http-client +## 0.7.6++* Add `applyBearerAuth` function [#457](https://github.com/snoyberg/http-client/pull/457/files)+ ## 0.7.5 * Force closing connections in case of exceptions throwing [#454](https://github.com/snoyberg/http-client/pull/454).
Network/HTTP/Client.hs view
@@ -138,6 +138,7 @@ , requestFromURI_ , defaultRequest , applyBasicAuth+ , applyBearerAuth , urlEncodedBody , getUri , setRequestIgnoreStatus
Network/HTTP/Client/Request.hs view
@@ -23,6 +23,7 @@ , addProxy , applyBasicAuth , applyBasicProxyAuth+ , applyBearerAuth , urlEncodedBody , needsGunzip , requestBuilder@@ -343,6 +344,22 @@ req { requestHeaders = authHeader : requestHeaders req } where authHeader = (CI.mk "Authorization", buildBasicAuth user passwd)++-- | Build a bearer-auth header value+buildBearerAuth ::+ S8.ByteString -- ^ Token+ -> S8.ByteString+buildBearerAuth token =+ S8.append "Bearer " token++-- | Add a Bearer Auth header to the given 'Request'+--+-- @since 0.7.6+applyBearerAuth :: S.ByteString -> Request -> Request+applyBearerAuth bearerToken req =+ req { requestHeaders = authHeader : requestHeaders req }+ where+ authHeader = (CI.mk "Authorization", buildBearerAuth bearerToken) -- | Add a proxy to the Request so that the Request when executed will use -- the provided proxy.
http-client.cabal view
@@ -1,5 +1,5 @@ name: http-client-version: 0.7.5+version: 0.7.6 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
test/Network/HTTP/ClientSpec.hs view
@@ -33,6 +33,18 @@ man <- newManager defaultManagerSettings res <- httpLbs req man responseStatus res `shouldBe` status405+ describe "bearer auth" $ do+ it "success" $ do+ initialReq <- parseUrlThrow "http://httpbin.org/bearer"+ let finalReq = applyBearerAuth "token" initialReq+ man <- newManager defaultManagerSettings+ res <- httpLbs finalReq man+ responseStatus res `shouldBe` status200+ it "failure" $ do+ req <- parseRequest "http://httpbin.org/bearer"+ man <- newManager defaultManagerSettings+ res <- httpLbs req man+ responseStatus res `shouldBe` status401 describe "redirects" $ do xit "follows redirects" $ do