http-conduit 1.9.4.5 → 1.9.5
raw patch · 4 files changed
+20/−16 lines, 4 files
Files
- Network/HTTP/Conduit.hs +6/−2
- Network/HTTP/Conduit/MultipartFormData.hs +5/−12
- Network/HTTP/Conduit/Request.hs +8/−1
- http-conduit.cabal +1/−1
Network/HTTP/Conduit.hs view
@@ -193,6 +193,7 @@ import Control.Exception.Lifted (throwIO, try, IOException, handle, fromException, toException) import qualified Network.TLS as TLS+import Control.Applicative import Control.Monad ((<=<)) import Control.Monad.IO.Class (MonadIO (liftIO)) import Control.Monad.Trans.Resource@@ -401,5 +402,8 @@ -- in production code. simpleHttp :: MonadIO m => String -> m L.ByteString simpleHttp url = liftIO $ withManager $ \man -> do- url' <- liftIO $ parseUrl url- fmap responseBody $ httpLbs url' man+ req <- liftIO $ parseUrl url+ responseBody <$> httpLbs (setConnectionClose req) man++setConnectionClose :: Request m -> Request m+setConnectionClose req = req{requestHeaders = ("Connection", "close") : requestHeaders req}
Network/HTTP/Conduit/MultipartFormData.hs view
@@ -71,12 +71,6 @@ import Data.Monoid (Monoid(..)) import Control.Monad -{-# INLINE _mmap #-}--- | Kludge to get rid of 'Functor' constraint-infixl 4 `_mmap`-_mmap :: Monad m => (a -> b) -> m a -> m b-_mmap = \f m -> m >>= return . f- -- | A single part of a multipart message. data Part m m' = Part { partName :: Text -- ^ Name of the corresponding \<input\>@@ -108,7 +102,7 @@ partFile :: (MonadIO m, Monad m') => Text -> FilePath -> Part m m' partFile n f = partFileRequestBodyM n f $ do- _mmap RequestBodyBS $ liftIO $ BS.readFile f+ liftM RequestBodyBS $ liftIO $ BS.readFile f -- | Stream 'Part' from a file. partFileSource :: (MonadIO m, MonadResource m') => Text -> FilePath -> Part m m'@@ -121,7 +115,7 @@ -- | 'partFileSourceChunked' will read a file and send it in chunks. -- -- Note that not all servers support this. Only use 'partFileSourceChunked'--- if you know the server you're sending to supports chunked request bodies. +-- if you know the server you're sending to supports chunked request bodies. partFileSourceChunked :: (Monad m, MonadResource m') => Text -> FilePath -> Part m m' partFileSourceChunked n f = partFileRequestBody n f $ do@@ -146,12 +140,12 @@ partFileRequestBodyM n f rqb = Part n (Just f) (Just $ defaultMimeLookup $ pack f) rqb -{-# INLINABLE cp #-}+{-# INLINE cp #-} cp :: BS.ByteString -> RequestBody m cp bs = RequestBodyBuilder (fromIntegral $ BS.length bs) $ copyByteString bs renderPart :: (Monad m, Monad m') => BS.ByteString -> Part m m' -> m (RequestBody m')-renderPart boundary (Part name mfilename mcontenttype get) = _mmap render get+renderPart boundary (Part name mfilename mcontenttype get) = liftM render get where render renderBody = cp "--" <> cp boundary <> cp "\r\n" <> cp "Content-Disposition: form-data; name=\""@@ -171,7 +165,7 @@ -- | Combine the 'Part's to form multipart/form-data body renderParts :: (Monad m, Monad m') => BS.ByteString -> [Part m m'] -> m (RequestBody m')-renderParts boundary parts = fin . mconcat `_mmap` mapM (renderPart boundary) parts+renderParts boundary parts = (fin . mconcat) `liftM` mapM (renderPart boundary) parts where fin = (<> cp "--" <> cp boundary <> cp "--\r\n") -- | Generate a boundary simillar to those generated by WebKit-based browsers.@@ -207,7 +201,6 @@ boundary <- liftIO webkitBoundary formDataBodyWithBoundary boundary a b -{-# INLINE formDataBodyPure #-} -- | Add form data to request without doing any IO. Your form data should only -- contain pure parts ('partBS', 'partLBS', 'partFileRequestBody'). You'll have -- to supply your own boundary (for example one generated by 'webkitBoundary')
Network/HTTP/Conduit/Request.hs view
@@ -26,6 +26,7 @@ import Data.Maybe (fromMaybe, isJust) import Data.Monoid (mempty, mappend)+import Data.String (IsString(..)) import Data.Default (Default (def)) @@ -42,7 +43,7 @@ import Network.URI (URI (..), URIAuth (..), parseURI, relativeTo, escapeURIString, isAllowedInURI) import Control.Monad.IO.Class (liftIO)-import Control.Exception.Lifted (Exception, toException, throwIO)+import Control.Exception.Lifted (Exception, toException, throw, throwIO) import Control.Failure (Failure (failure)) import qualified Data.CaseInsensitive as CI import qualified Data.ByteString.Base64 as B64@@ -203,6 +204,12 @@ else return (Just remainingTime, res) , cookieJar = Just def }++instance IsString (Request m) where+ fromString s =+ case parseUrl s of+ Left e -> throw (e :: HttpException)+ Right r -> r -- | Always decompress a compressed stream. alwaysDecompress :: ContentType -> Bool
http-conduit.cabal view
@@ -1,5 +1,5 @@ name: http-conduit-version: 1.9.4.5+version: 1.9.5 license: BSD3 license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>