http-client 0.6.0 → 0.6.1
raw patch · 3 files changed
+19/−8 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Network.HTTP.Client.Internal: setUriEither :: Request -> URI -> Either String Request
Files
- ChangeLog.md +4/−0
- Network/HTTP/Client/Request.hs +14/−7
- http-client.cabal +1/−1
ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for http-client +## 0.6.1++* Add `setUriEither` to `Network.HTTP.Client.Internal`+ ## 0.6.0 * Generalize `renderParts` over arbitrary applicative functors. One particular
Network/HTTP/Client/Request.hs view
@@ -17,6 +17,7 @@ , setUriRelative , getUri , setUri+ , setUriEither , browserDecompress , alwaysDecompress , addProxy@@ -226,9 +227,18 @@ -- | Validate a 'URI', then add it to the request. setUri :: MonadThrow m => Request -> URI -> m Request-setUri req uri = do+setUri req uri = either throwInvalidUrlException return (setUriEither req uri)+ where+ throwInvalidUrlException = throwM . InvalidUrlException (show uri)++-- | A variant of `setUri` that returns an error message on validation errors,+-- instead of propagating them with `throwM`.+--+-- @since 0.6.1+setUriEither :: Request -> URI -> Either String Request+setUriEither req uri = do sec <- parseScheme uri- auth <- maybe (failUri "URL must be absolute") return $ uriAuthority uri+ auth <- maybe (Left "URL must be absolute") return $ uriAuthority uri port' <- parsePort sec auth return $ applyAnyUriBasedAuth uri req { host = S8.pack $ uriRegName auth@@ -241,20 +251,17 @@ , queryString = S8.pack $ uriQuery uri } where- failUri :: MonadThrow m => String -> m a- failUri = throwM . InvalidUrlException (show uri)- parseScheme URI{uriScheme = scheme} = case map toLower scheme of "http:" -> return False "https:" -> return True- _ -> failUri "Invalid scheme"+ _ -> Left "Invalid scheme" parsePort sec URIAuth{uriPort = portStr} = case portStr of -- If the user specifies a port, then use it ':':rest -> maybe- (failUri "Invalid port")+ (Left "Invalid port") return (readDec rest) -- Otherwise, use the default port
http-client.cabal view
@@ -1,5 +1,5 @@ name: http-client-version: 0.6.0+version: 0.6.1 synopsis: An HTTP client engine 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