Skip to content

Commit

Permalink
Version uptick, documentation updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrap committed Jan 1, 2018
1 parent 16a5399 commit 8d3faf6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Network/Wreq.hs
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,15 @@ customMethodWith method opts url = runRead =<< prepareMethod methodBS opts url
-- >>> r <- customHistoriedMethod "GET" "http://httpbin.org/redirect/3"
-- >>> length (r ^. hrRedirects)
-- 3
--
-- @since 0.5.2.0
customHistoriedMethod :: String -> String -> IO (HistoriedResponse L.ByteString)
customHistoriedMethod method url = customHistoriedMethodWith method defaults url

-- | Issue a custom request method request, using the supplied 'Options'.
-- Keep track of redirects and return the 'HistoriedResponse'.
--
-- @since 0.5.2.0
customHistoriedMethodWith :: String -> Options -> String -> IO (HistoriedResponse L.ByteString)
customHistoriedMethodWith method opts url =
runReadHistory =<< prepareMethod methodBS opts url
Expand Down
1 change: 1 addition & 0 deletions Network/Wreq/Internal/Lens.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module Network.Wreq.Internal.Lens
, requestHeaders
, requestBody
, requestVersion
, requestManagerOverride
, onRequestBodyException
, proxy
, hostAddress
Expand Down
12 changes: 12 additions & 0 deletions Network/Wreq/Session.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ withSession act = newSession >>= act
--
-- This session manages cookies and uses default session manager
-- configuration.
--
-- @since 0.5.2.0
newSession :: IO Session
newSession = newSessionControl (Just (HTTP.createCookieJar [])) defaultManagerSettings

Expand All @@ -125,6 +127,8 @@ withAPISession act = newAPISession >>= act
-- This uses the default session manager settings, but does not manage
-- cookies. It is intended for use with REST-like HTTP-based APIs,
-- which typically do not use cookies.
--
-- @since 0.5.2.0
newAPISession :: IO Session
newAPISession = newSessionControl Nothing defaultManagerSettings

Expand All @@ -146,6 +150,8 @@ withSessionControl mj settings act = do
{-# DEPRECATED withSessionControl "Use newSessionControl instead." #-}

-- | Create a session, using the given cookie jar and manager settings.
--
-- @since 0.5.2.0
newSessionControl :: Maybe HTTP.CookieJar
-- ^ If 'Nothing' is specified, no cookie management
-- will be performed.
Expand All @@ -161,6 +167,8 @@ newSessionControl mj settings = do
}

-- | Extract current 'Network.HTTP.Client.CookieJar' from a 'Session'
--
-- @since 0.5.2.0
getSessionCookieJar :: Session -> IO (Maybe HTTP.CookieJar)
getSessionCookieJar = traverse readIORef . seshCookies

Expand Down Expand Up @@ -226,6 +234,8 @@ customMethodWith method opts sesh url = run string sesh =<< prepareMethod method
methodBS = BC8.pack method

-- | 'Session'-specific version of 'Network.Wreq.customHistoriedMethodWith'.
--
-- @since 0.5.2.0
customHistoriedMethodWith :: String -> Options -> Session -> String -> IO (HistoriedResponse L.ByteString)
customHistoriedMethodWith method opts sesh url =
runHistory stringHistory sesh =<< prepareMethod methodBS opts url
Expand All @@ -241,6 +251,8 @@ customPayloadMethodWith method opts sesh url payload =
methodBS = BC8.pack method

-- | 'Session'-specific version of 'Network.Wreq.customHistoriedPayloadMethodWith'.
--
-- @since 0.5.2.0
customHistoriedPayloadMethodWith :: Postable a => String -> Options -> Session -> String -> a
-> IO (HistoriedResponse L.ByteString)
customHistoriedPayloadMethodWith method opts sesh url payload =
Expand Down
6 changes: 3 additions & 3 deletions httpbin/HttpBin/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ respond act = do
params = Map.foldlWithKey' step Map.empty .
rqQueryParams $ req
wibble (k,v) = (decodeUtf8 (original k), decodeUtf8 v)
rqHeaders = headers req
hdrs = Map.fromList . map wibble . listHeaders $ rqHeaders
url = case getHeader "Host" rqHeaders of
rqHdrs = headers req
hdrs = Map.fromList . map wibble . listHeaders $ rqHdrs
url = case getHeader "Host" rqHdrs of
Nothing -> []
Just host -> [("url", toJSON . decodeUtf8 $
"http://" <> host <> rqURI req)]
Expand Down
2 changes: 1 addition & 1 deletion wreq.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: wreq
version: 0.5.1.1
version: 0.5.2.0
synopsis: An easy-to-use HTTP client library.
description:
.
Expand Down

0 comments on commit 8d3faf6

Please sign in to comment.