summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichaelSnoyman <>2012-06-18 06:59:21 (GMT)
committerhdiff <hdiff@luite.com>2012-06-18 06:59:21 (GMT)
commit688f6a578a7ec5b20c50b4ba5dc3107018ed8d45 (patch)
tree038fe5586d66ede79ce53bc4e46c7b3f0673d886
parenta9ef2886259e8385497014f52118997900d7b814 (diff)
version 1.4.1.91.4.1.9
-rw-r--r--Network/HTTP/Conduit.hs16
-rw-r--r--Network/HTTP/Conduit/Request.hs9
-rw-r--r--Network/HTTP/Conduit/Response.hs20
-rw-r--r--http-conduit.cabal2
4 files changed, 32 insertions, 15 deletions
diff --git a/Network/HTTP/Conduit.hs b/Network/HTTP/Conduit.hs
index 997fa1c..c4d7928 100644
--- a/Network/HTTP/Conduit.hs
+++ b/Network/HTTP/Conduit.hs
@@ -49,6 +49,22 @@
-- > $ simpleHttp "http://www.haskell.org/" >>= L.putStr
-- >
-- > Cookies are implemented according to RFC 6265.
+--
+-- Note that by default, the functions in this package will throw exceptions
+-- for non-2xx status codes. If you would like to avoid this, you should use
+-- 'checkStatus', e.g.:
+--
+-- > import Data.Conduit.Binary (sinkFile)
+-- > import Network.HTTP.Conduit
+-- > import qualified Data.Conduit as C
+-- > import Network
+-- >
+-- > main :: IO ()
+-- > main = withSocketsDo $ do
+-- > request' <- parseUrl "http://www.yesodweb.com/does-not-exist"
+-- > let request = request' { checkStatus = \_ _ -> Nothing }
+-- > res <- withManager $ httpLbs request
+-- > print res
module Network.HTTP.Conduit
( -- * Perform a request
simpleHttp
diff --git a/Network/HTTP/Conduit/Request.hs b/Network/HTTP/Conduit/Request.hs
index 28dd97a..83ccfc4 100644
--- a/Network/HTTP/Conduit/Request.hs
+++ b/Network/HTTP/Conduit/Request.hs
@@ -331,10 +331,11 @@ requestBuilder req =
<> fromByteString " "
<> (case S8.uncons $ path req of
Just ('/', _) -> fromByteString $ path req
- _ -> fromByteString "/" <> fromByteString (path req))
- <> (if S8.null (queryString req)
- then mempty
- else fromChar '?' <> fromByteString (queryString req))
+ _ -> fromChar '/' <> fromByteString (path req))
+ <> (case S8.uncons $ queryString req of
+ Nothing -> mempty
+ Just ('?', _) -> fromByteString $ queryString req
+ _ -> fromChar '?' <> fromByteString (queryString req))
<> fromByteString " HTTP/1.1\r\n"
<> foldr
(\a b -> headerPairToBuilder a <> b)
diff --git a/Network/HTTP/Conduit/Response.hs b/Network/HTTP/Conduit/Response.hs
index 8ee48b1..5555eb9 100644
--- a/Network/HTTP/Conduit/Response.hs
+++ b/Network/HTTP/Conduit/Response.hs
@@ -75,16 +75,16 @@ getRedirectedRequest req hs code
| 300 <= code && code < 400 = do
l' <- lookup "location" hs
req' <- setUriRelative req =<< parseURIReference (S8.unpack l')
- return req'
- { method =
- -- According to the spec, this should *only* be for
- -- status code 303. However, almost all clients
- -- mistakenly implement it for 302 as well. So we
- -- have to be wrong like everyone else...
- if code == 302 || code == 303
- then "GET"
- else method req'
- }
+ return $
+ if code == 302 || code == 303
+ -- According to the spec, this should *only* be for status code
+ -- 303. However, almost all clients mistakenly implement it for
+ -- 302 as well. So we have to be wrong like everyone else...
+ then req'
+ { method = "GET"
+ , requestBody = RequestBodyBS ""
+ }
+ else req'
| otherwise = Nothing
-- | Convert a 'Response' that has a 'C.Source' body to one with a lazy
diff --git a/http-conduit.cabal b/http-conduit.cabal
index 8907349..c426305 100644
--- a/http-conduit.cabal
+++ b/http-conduit.cabal
@@ -1,5 +1,5 @@
name: http-conduit
-version: 1.4.1.8
+version: 1.4.1.9
license: BSD3
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>