packages feed

http-client 0.4.20 → 0.4.21

raw patch · 3 files changed

+19/−4 lines, 3 files

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+## 0.4.21++* Support `no_proxy` environment variable. [#140](https://github.com/snoyberg/http-client/issues/140) [#145](https://github.com/snoyberg/http-client/pull/145)+ ## 0.4.20  * Expose `brReadSome`
Network/HTTP/Client/Manager.hs view
@@ -37,6 +37,7 @@  import qualified Blaze.ByteString.Builder as Blaze +import Data.Char (toLower) import Data.Text (Text) import qualified Data.Text as T import Data.Text.Read (decimal)@@ -506,7 +507,9 @@ envHelper name eh = do     env <- getEnvironment     let lenv = Map.fromList $ map (first $ T.toLower . T.pack) env-    case lookup (T.unpack name) env <|> Map.lookup name lenv of+        lookupEnvVar n = lookup (T.unpack n) env <|> Map.lookup n lenv+        noProxyDomains = domainSuffixes (lookupEnvVar "no_proxy")+    case lookupEnvVar name of         Nothing  -> return noEnvProxy         Just ""  -> return noEnvProxy         Just str -> do@@ -541,9 +544,17 @@                  Just $ (Proxy (S8.pack $ U.uriRegName auth) port, muserpass)             return $ \req ->-                maybe id (uncurry applyBasicProxyAuth) muserpass-                req { proxy = Just p }+                if host req `hasDomainSuffixIn` noProxyDomains+                then noEnvProxy req+                else maybe id (uncurry applyBasicProxyAuth) muserpass+                     req { proxy = Just p }     where noEnvProxy = case eh of             EHFromRequest -> id             EHNoProxy     -> \req -> req { proxy = Nothing }             EHUseProxy p  -> \req -> req { proxy = Just p  }+          prefixed s | S8.head s == '.' = s+                     | otherwise = S8.cons '.' s+          domainSuffixes Nothing = []+          domainSuffixes (Just "") = []+          domainSuffixes (Just no_proxy) = [prefixed $ S8.dropWhile (== ' ') suffix | suffix <- S8.split ',' (S8.pack (map toLower no_proxy)), not (S8.null suffix)]+          hasDomainSuffixIn host = any (`S8.isSuffixOf` prefixed (S8.map toLower host))
http-client.cabal view
@@ -1,5 +1,5 @@ name:                http-client-version:             0.4.20+version:             0.4.21 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