http-enumerator 0.5.1 → 0.6.0
raw patch · 4 files changed
+17/−20 lines, 4 filesdep +tls-extradep ~tls
Dependencies added: tls-extra
Dependency ranges changed: tls
Files
- Network/HTTP/Enumerator.hs +11/−10
- Network/TLS/Client/Enumerator.hs +2/−7
- http-enumerator.cabal +3/−2
- test.hs +1/−1
Network/HTTP/Enumerator.hs view
@@ -109,6 +109,7 @@ import qualified Data.IORef as I import Control.Applicative ((<$>)) import Data.Certificate.X509 (X509)+import Network.TLS.Extra (certificateVerifyChain, certificateVerifyDomain) getSocket :: String -> Int -> IO NS.Socket getSocket host' port' = do@@ -341,13 +342,10 @@ -- -- Since this function uses 'Failure', the return monad can be anything that is -- an instance of 'Failure', such as 'IO' or 'Maybe'.-parseUrl :: Failure HttpException m => W.Ascii -> m (Request m')-parseUrl = parseUrlS . S8.unpack--parseUrlS :: Failure HttpException m => String -> m (Request m')-parseUrlS s@('h':'t':'t':'p':':':'/':'/':rest) = parseUrl1 s False rest-parseUrlS s@('h':'t':'t':'p':'s':':':'/':'/':rest) = parseUrl1 s True rest-parseUrlS x = failure $ InvalidUrlException x "Invalid scheme"+parseUrl :: Failure HttpException m => String -> m (Request m')+parseUrl s@('h':'t':'t':'p':':':'/':'/':rest) = parseUrl1 s False rest+parseUrl s@('h':'t':'t':'p':'s':':':'/':'/':rest) = parseUrl1 s True rest+parseUrl x = failure $ InvalidUrlException x "Invalid scheme" parseUrl1 :: Failure HttpException m => String -> Bool -> String -> m (Request m')@@ -364,7 +362,10 @@ { host = S8.pack hostname , port = port' , secure = sec- , checkCerts = const $ return True+ , checkCerts = \x ->+ if certificateVerifyDomain hostname x+ then certificateVerifyChain x+ else return False , requestHeaders = [] , path = S8.pack $ if null path'@@ -424,7 +425,7 @@ -- This function will 'failure' an 'HttpException' for any response with a -- non-2xx status code. It uses 'parseUrl' to parse the input. This function -- essentially wraps 'httpLbsRedirect'.-simpleHttp :: (MonadIO m, Failure HttpException m) => W.Ascii -> m L.ByteString+simpleHttp :: (MonadIO m, Failure HttpException m) => String -> m L.ByteString simpleHttp url = do url' <- parseUrl url Response sc _ b <- liftIO $ withManager $ httpLbsRedirect url'@@ -476,7 +477,7 @@ , S8.unpack l'' ] _ -> S8.unpack l''- l <- lift $ parseUrlS l'+ l <- lift $ parseUrl l' let req' = req { host = host l , port = port l
Network/TLS/Client/Enumerator.hs view
@@ -20,6 +20,7 @@ ( Iteratee (..), Enumerator, Step (..), Stream (..), continue, returnI ) import Data.Certificate.X509 (X509)+import Network.TLS.Extra (ciphersuite_all) data ConnInfo = ConnInfo { connRead :: IO [ByteString]@@ -61,7 +62,7 @@ let tcp = defaultParams { pConnectVersion = TLS10 , pAllowedVersions = [ TLS10, TLS11 ]- , pCiphers = ciphers+ , pCiphers = ciphersuite_all , onCertificatesRecv = onCerts } esrand <- liftIO makeSRandomGen@@ -79,9 +80,3 @@ if L.null x then recvD istate else return $ L.toChunks x- ciphers =- [ cipher_AES128_SHA1- , cipher_AES256_SHA1- , cipher_RC4_128_MD5- , cipher_RC4_128_SHA1- ]
http-enumerator.cabal view
@@ -1,5 +1,5 @@ name: http-enumerator-version: 0.5.1+version: 0.6.0 license: BSD3 license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>@@ -31,7 +31,8 @@ , zlib-enum >= 0.2 && < 0.3 , http-types >= 0.6 && < 0.7 , blaze-builder-enumerator >= 0.2 && < 0.3- , tls >= 0.4 && < 0.5+ , tls >= 0.5.1 && < 0.6+ , tls-extra >= 0.1.6 && < 0.2 , monad-control >= 0.2 && < 0.3 , containers >= 0.2 && < 0.5 , certificate >= 0.7 && < 0.8
test.hs view
@@ -11,7 +11,7 @@ main :: IO () main = withSocketsDo $ do [url] <- getArgs- _req2 <- parseUrl $ S8.pack url+ _req2 <- parseUrl url {- let req = urlEncodedBody [ ("foo", "bar")