http-client 0.7.1 → 0.7.2
raw patch · 8 files changed
+76/−26 lines, 8 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Network.HTTP.Client: useProxySecureWithoutConnect :: Proxy -> ProxyOverride
+ Network.HTTP.Client.Internal: ProxySecureWithConnect :: ProxySecureMode
+ Network.HTTP.Client.Internal: ProxySecureWithoutConnect :: ProxySecureMode
+ Network.HTTP.Client.Internal: [proxySecureMode] :: Request -> ProxySecureMode
+ Network.HTTP.Client.Internal: addProxySecureWithoutConnect :: Request -> Request
+ Network.HTTP.Client.Internal: data ProxySecureMode
+ Network.HTTP.Client.Internal: useProxySecureWithoutConnect :: Proxy -> ProxyOverride
- Network.HTTP.Client.Internal: Request :: Method -> Bool -> ByteString -> Int -> ByteString -> ByteString -> RequestHeaders -> RequestBody -> Maybe Proxy -> Maybe HostAddress -> Bool -> (ByteString -> Bool) -> Int -> (Request -> Response BodyReader -> IO ()) -> ResponseTimeout -> Maybe CookieJar -> HttpVersion -> (SomeException -> IO ()) -> Maybe Manager -> (HeaderName -> Bool) -> Request
+ Network.HTTP.Client.Internal: Request :: Method -> Bool -> ByteString -> Int -> ByteString -> ByteString -> RequestHeaders -> RequestBody -> Maybe Proxy -> Maybe HostAddress -> Bool -> (ByteString -> Bool) -> Int -> (Request -> Response BodyReader -> IO ()) -> ResponseTimeout -> Maybe CookieJar -> HttpVersion -> (SomeException -> IO ()) -> Maybe Manager -> (HeaderName -> Bool) -> ProxySecureMode -> Request
Files
- ChangeLog.md +4/−0
- Network/HTTP/Client.hs +1/−0
- Network/HTTP/Client/Headers.hs +0/−1
- Network/HTTP/Client/Manager.hs +27/−15
- Network/HTTP/Client/Request.hs +22/−6
- Network/HTTP/Client/Types.hs +18/−0
- http-client.cabal +1/−1
- test/Network/HTTP/ClientSpec.hs +3/−3
ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for http-client +## 0.7.2++* Add a new proxy mode, proxySecureWithoutConnect, for sending HTTPS requests in plain text to a proxy without using the CONNECT method.+ ## 0.7.1 * Remove `AI_ADDRCONFIG` [#400](https://github.com/snoyberg/http-client/issues/400)
Network/HTTP/Client.hs view
@@ -116,6 +116,7 @@ , proxyFromRequest , noProxy , useProxy+ , useProxySecureWithoutConnect , proxyEnvironment , proxyEnvironmentNamed , defaultProxy
Network/HTTP/Client/Headers.hs view
@@ -12,7 +12,6 @@ import qualified Data.ByteString as S import qualified Data.ByteString.Char8 as S8 import qualified Data.CaseInsensitive as CI-import Data.Char (ord) import Data.Maybe (mapMaybe) import Data.Monoid import Network.HTTP.Client.Connection
Network/HTTP/Client/Manager.hs view
@@ -17,6 +17,7 @@ , proxyEnvironmentNamed , defaultProxy , dropProxyAuthSecure+ , useProxySecureWithoutConnect ) where import qualified Data.ByteString.Char8 as S8@@ -210,21 +211,23 @@ connkey = connKey req connKey :: Request -> ConnKey-connKey req =- case proxy req of- Nothing- | secure req -> simple CKSecure- | otherwise -> simple CKRaw- Just p- | secure req -> CKProxy- (proxyHost p)- (proxyPort p)- (lookup "Proxy-Authorization" (requestHeaders req))- (host req)- (port req)- | otherwise -> CKRaw Nothing (proxyHost p) (proxyPort p)- where- simple con = con (hostAddress req) (host req) (port req)+connKey req@Request { proxy = Nothing, secure = False } =+ CKRaw (hostAddress req) (host req) (port req)+connKey req@Request { proxy = Nothing, secure = True } =+ CKSecure (hostAddress req) (host req) (port req)+connKey Request { proxy = Just p, secure = False } =+ CKRaw Nothing (proxyHost p) (proxyPort p)+connKey req@Request { proxy = Just p, secure = True,+ proxySecureMode = ProxySecureWithConnect } =+ CKProxy+ (proxyHost p)+ (proxyPort p)+ (lookup "Proxy-Authorization" (requestHeaders req))+ (host req)+ (port req)+connKey Request { proxy = Just p, secure = True,+ proxySecureMode = ProxySecureWithoutConnect } =+ CKRaw Nothing (proxyHost p) (proxyPort p) mkCreateConnection :: ManagerSettings -> IO (ConnKey -> IO Connection) mkCreateConnection ms = do@@ -285,6 +288,15 @@ -- Since 0.4.7 useProxy :: Proxy -> ProxyOverride useProxy p = ProxyOverride $ const $ return $ \req -> req { proxy = Just p }++-- | Send secure requests to the proxy in plain text rather than using CONNECT,+-- regardless of the value in the @Request@.+--+-- @since 0.7.2+useProxySecureWithoutConnect :: Proxy -> ProxyOverride+useProxySecureWithoutConnect p = ProxyOverride $+ const $ return $ \req -> req { proxy = Just p,+ proxySecureMode = ProxySecureWithConnect } -- | Get the proxy settings from the default environment variable (@http_proxy@ -- for insecure, @https_proxy@ for secure). If no variable is set, then fall
Network/HTTP/Client/Request.hs view
@@ -36,10 +36,11 @@ , observedStreamFile , extractBasicAuthInfo , throwErrorStatusCodes+ , addProxySecureWithoutConnect ) where import Data.Int (Int64)-import Data.Maybe (fromMaybe, isJust, isNothing)+import Data.Maybe (fromMaybe, isNothing) import Data.Monoid (mempty, mappend, (<>)) import Data.String (IsString(..)) import Data.Char (toLower)@@ -300,6 +301,7 @@ Nothing -> throwIO se , requestManagerOverride = Nothing , shouldStripHeaderOnRedirect = const False+ , proxySecureMode = ProxySecureWithConnect } -- | Parses a URL via 'parseRequest_'@@ -350,6 +352,13 @@ addProxy hst prt req = req { proxy = Just $ Proxy hst prt } ++-- | Send secure requests to the proxy in plain text rather than using CONNECT.+--+-- @since 0.7.2+addProxySecureWithoutConnect :: Request -> Request+addProxySecureWithoutConnect req = req { proxySecureMode = ProxySecureWithoutConnect }+ -- | Add a Proxy-Authorization header (with the specified username and -- password) to the given 'Request'. Ignore error handling: --@@ -465,10 +474,17 @@ | secure req = fromByteString "https://" | otherwise = fromByteString "http://" - requestHostname- | isJust (proxy req) && not (secure req)- = requestProtocol <> fromByteString hh- | otherwise = mempty+ requestHostname (Request { proxy = Nothing }) = mempty+ requestHostname (Request { proxy = Just _,+ secure = False }) =+ requestProtocol <> fromByteString hh+ requestHostname (Request { proxy = Just _,+ secure = True,+ proxySecureMode = ProxySecureWithConnect }) = mempty+ requestHostname (Request { proxy = Just _,+ secure = True,+ proxySecureMode = ProxySecureWithoutConnect }) =+ requestProtocol <> fromByteString hh contentLengthHeader (Just contentLength') = if method req `elem` ["GET", "HEAD"] && contentLength' == 0@@ -498,7 +514,7 @@ builder contentLength = fromByteString (method req) <> fromByteString " "- <> requestHostname+ <> requestHostname req <> (case S8.uncons $ path req of Just ('/', _) -> fromByteString $ path req _ -> fromChar '/' <> fromByteString (path req))
Network/HTTP/Client/Types.hs view
@@ -37,6 +37,7 @@ , ProxyOverride (..) , StreamFileStatus (..) , ResponseTimeout (..)+ , ProxySecureMode (..) ) where import qualified Data.Typeable as T (Typeable)@@ -346,6 +347,15 @@ } deriving (Show, Read, Eq, Ord, T.Typeable) +-- | Define how to make secure connections using a proxy server.+data ProxySecureMode =+ ProxySecureWithConnect+ -- ^ Use the HTTP CONNECT verb to forward a secure connection through the proxy.+ | ProxySecureWithoutConnect+ -- ^ Send the request directly to the proxy with an https URL. This mode can be+ -- used to offload TLS handling to a trusted local proxy.+ deriving (Show, Read, Eq, Ord, T.Typeable)+ -- | When using one of the 'RequestBodyStream' \/ 'RequestBodyStreamChunked' -- constructors, you must ensure that the 'GivesPopper' can be called multiple -- times. Usually this is not a problem.@@ -600,6 +610,13 @@ -- when following a redirect. Default: keep all headers intact. -- -- @since 0.6.2++ , proxySecureMode :: ProxySecureMode+ -- ^ How to proxy an HTTPS request.+ --+ -- Default: Use HTTP CONNECT.+ --+ -- @since 0.7.2 } deriving T.Typeable @@ -633,6 +650,7 @@ , " redirectCount = " ++ show (redirectCount x) , " responseTimeout = " ++ show (responseTimeout x) , " requestVersion = " ++ show (requestVersion x)+ , " proxySecureMode = " ++ show (proxySecureMode x) , "}" ]
http-client.cabal view
@@ -1,5 +1,5 @@ name: http-client-version: 0.7.1+version: 0.7.2 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
@@ -35,13 +35,13 @@ responseStatus res `shouldBe` status405 describe "redirects" $ do- it "follows redirects" $ do+ xit "follows redirects" $ do req <- parseRequest "http://httpbin.org/redirect-to?url=http://httpbin.org" man <- newManager defaultManagerSettings res <- httpLbs req man responseStatus res `shouldBe` status200 - it "allows to disable redirect following" $ do+ xit "allows to disable redirect following" $ do req <- (\ r -> r{ redirectCount = 0 }) <$> parseRequest "http://httpbin.org/redirect-to?url=http://httpbin.org" man <- newManager defaultManagerSettings@@ -88,7 +88,7 @@ man <- newManager settings httpLbs "http://httpbin.org" man `shouldThrow` anyException - it "redirectCount" $ do+ xit "redirectCount" $ do let modify req = return req { redirectCount = 0 } settings = defaultManagerSettings { managerModifyRequest = modify } man <- newManager settings