h*vp      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~3.13.2 2016@present Mark Karpov BSD 3 clause$Mark Karpov  experimentalportable Safe-Inferred "%&1o}reqA type-level tag that specifies URL scheme used (and thus if HTTPS is enabled). This is used to force TLS requirement for some authentication s.reqHTTPreqHTTPSreqA simple type isomorphic to  that we only have for better error messages. We use it as a kind and its data constructors as type-level tags. See also: * and .reqIndeed can have a bodyreqShould not have a bodyreq$Exceptions that this library throws.reqA wrapper with an  from Network.HTTP.ClientreqA wrapper with Aeson-produced  describing why decoding failedreqThis wrapper is only used to attach a type-level tag to a given type. This is necessary to define instances of  for any thing that implements * or 9. Without the tag, GHC can't see the difference between * method =>  method and  body =>  body when it decides which instance to use (i.e. the constraints are taken into account later, when instance is already chosen).req.The main class for things that are @parts@ of ! in the sense that if we have a ,, then we know how to apply an instance of ' changing/overwriting something in it.  is a monoid of endomorphisms under composition, it's used to chain different request components easier using ().Note2: this type class is not a part of the public API.reqGet a function that takes a + and changes it somehow returning another . For example, the * instance of 5 just overwrites method. The function is wrapped in  so it's easier to chain such @modifying applications@ together building bigger and bigger s. reqA type class for response interpretations. It allows us to describe how to consume the response from a   and produce the final result that is to be returned to the user. reqThe associated type is the type of body that can be extracted from an instance of  . req/The method describes how to get the underlying  record. reqThis method describes how to consume response body and, more generally, obtain response value from  .Note:  is nothing but  . You should call this action repeatedly until it yields the empty . In that case streaming of response is finished (which apparently leads to closing of the connection, so don't call the reader after it has returned the empty  once) and you can concatenate the chunks to obtain the final result. (Of course you could as well stream the contents to a file or do whatever you want.)Note9: signature of this function was changed in the version 1.0.0. req The value of "Accept" header. This is useful, for example, if a website supports both XML and JSON: responses, and decides what to reply with based on what Accept headers you have sent.Note: manually specified Options that set the "Accept" header will take precedence.reqMake a request and interpret the body of the response as a lazy .reqMake a request and interpret the body of the response as a strict .reqMake a request and interpret the body of the response as JSON. The K method of J3 instance corresponding to monad in which you use M will determine what to do in the case when parsing fails (the  constructor will be used).req3Make a request and ignore the body of the response.reqA type class for query-parameter-like things. The reason to have an overloaded  is to be able to use it as an  and as a  when constructing form URL encoded request bodies. Having the same syntax for these cases seems natural and user-friendly.reqCreate a query parameter with given name and value. If value is , it won't be included at all (i.e. you create a flag this way). It's recommended to use (^) and _: instead of this method, because they are easier to read. req0Get the query parameter names and values set by .req The opaque  type is a  you can use to pack collection of optional parameters like query parameters and headers. See sections below to learn which  primitives are available.req;This type function allows any HTTP body if method says it &. When the method says it should have ", the only body option to use is '.reqThe type function recognizes ' as having , while any other body option . This forces the user to use ' with =4 method and other methods that should not have body.req Nothing% if this behavior is not desirable).(When the value this function returns is ), nothing will happen. When it there is  inside , it will be thrown.Throwing is better then just returning a request with non-2xx status code because in that case something is wrong and we need a way to short-cut execution (also remember that Req retries automatically on request timeouts and such, so when your request fails, it's certainly something exceptional). The thrown exception is caught by the library though and is available in K.Note9: signature of this function was changed in the version 1.0.0.Freq9The retry policy to use for request retrying. By default def is used (see ).Note5: signature of this function was changed to disallow  in version 1.0.0. and then changed back to its current form in 3.1.0.Greq;The function is used to decide whether to retry a request. + means that the request should be retried.Note9: signature of this function was changed in the version 1.0.0.Hreq Similar to G, but is used to decide when to retry requests that resulted in an exception. By default it retries on response timeout and connection timeout (changed in version 3.8.0).Ireq0Max length of preview fragment of response body.JreqA type class for monads that support performing HTTP requests. Typically, you only need to define the K" method unless you want to tweak @.Kreq'This method describes how to deal with  that was caught by the library. One option is to re-throw it if you are OK with exceptions, but if you prefer working with something like ), this is the right place to pass it to .Lreq Return the @ to be used when performing HTTP requests. Default implementation returns its def value, which is described in the documentation for the type. Common usage pattern with manually defined L is to return some hard-coded value, or a value extracted from < if a more flexible approach to configuration is desirable.MreqMake an HTTP request. The function takes 5 arguments, 4 of which specify required parameters and the final 2 argument is a collection of optional parameters.*Let's go through all the arguments first: %req method url body response options.method is an HTTP method such as = or ;. The documentation has a dedicated section about HTTP methods below.url is a ) that describes location of resource you want to interact with.body is a body option such as ' or %. The tutorial has a section about HTTP bodies, but usage is very straightforward and should be clear from the examples.response is a type hint how to make and interpret response of an HTTP request. Out-of-the-box it can be the following:pqr (to get a strict )s (to get a lazy ) Finally, options is a  that holds a composite  for all other optional settings like query parameters, headers, non-standard port number, etc. There are quite a few things you can put there, see the corresponding section in the documentation. If you don't need anything at all, pass .Note that if you use M to do all your requests, connection sharing and reuse is done for you automatically.3See the examples below to get on the speed quickly.ExamplesFirst, this is a piece of boilerplate that should be in place before you try the examples: {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} module Main (main) where import Control.Monad import Control.Monad.IO.Class import Data.Aeson import Data.Maybe (fromJust) import Data.Monoid ((<>)) import Data.Text (Text) import GHC.Generics import Network.HTTP.Req import qualified Data.ByteString.Char8 as B import qualified Text.URI as URI'We will be making requests against the  https://httpbin.org service.(Make a GET request, grab 5 random bytes: main :: IO () main = runReq defaultHttpConfig $ do let n :: Int n = 5 bs <- req GET (https "httpbin.org" /: "bytes" /~ n) NoReqBody bsResponse mempty liftIO $ B.putStrLn (responseBody bs)1The same, but now we use a query parameter named "seed"# to control seed of the generator: main :: IO () main = runReq defaultHttpConfig $ do let n, seed :: Int n = 5 seed = 100 bs <- req GET (https "httpbin.org" /: "bytes" /~ n) NoReqBody bsResponse $ "seed" =: seed liftIO $ B.putStrLn (responseBody bs)8POST JSON data and get some info about the POST request: data MyData = MyData { size :: Int , color :: Text } deriving (Show, Generic) instance ToJSON MyData instance FromJSON MyData main :: IO () main = runReq defaultHttpConfig $ do let myData = MyData { size = 6 , color = "Green" } v <- req POST (https "httpbin.org" /: "post") (ReqBodyJson myData) jsonResponse mempty liftIO $ print (responseBody v :: Value)Sending URL-encoded body: main :: IO () main = runReq defaultHttpConfig $ do let params = "foo" =: ("bar" :: Text) <> queryFlag "baz" response <- req POST (https "httpbin.org" /: "post") (ReqBodyUrlEnc params) jsonResponse mempty liftIO $ print (responseBody response :: Value)Using various optional parameters and URL that is not known in advance: main :: IO () main = runReq defaultHttpConfig $ do -- This is an example of what to do when URL is given dynamically. Of -- course in a real application you may not want to use 'fromJust'. uri <- URI.mkURI "https://httpbin.org/get?foo=bar" let (url, options) = fromJust (useHttpsURI uri) response <- req GET url NoReqBody jsonResponse $ "from" =: (15 :: Int) <> "to" =: (67 :: Int) <> basicAuth "username" "password" <> options <> -- contains the ?foo=bar part port 443 -- here you can put any port of course liftIO $ print (responseBody response :: Value)Nreq A version of M7 that does not use one of the predefined instances of  ( but instead allows the user to consume   manually, in a custom way.Oreq A version of M% that takes a callback to modify the 2, but otherwise performs the request identically.reqThe default handler function that the higher-level request functions pass to P. Internal function.Preq Mostly like M with respect to its arguments, but accepts a callback that allows to perform a request in arbitrary fashion.This function does not perform handling/wrapping exceptions, checking response (with E#), and retrying. It only prepares  and allows you to use it.Qreq,Perform an action using the global implicit  that the rest of the library uses. This allows to reuse connections that the  controls.req The global  that M uses. Here we just go with the default settings, so users don't need to deal with this manager stuff at all, but when we create a request, instance @& can affect the default settings via L.A note about safety, in case ( looks suspicious to you. The value of  is named and lives on top level. This means it will be shared, i.e. computed only once on the first use of the manager. From that moment on the  will be just reused@exactly the behavior we want here in order to maximize connection sharing. GHC could spoil the plan by inlining the definition, hence the NOINLINE pragma.RreqThe default value of @.SreqRun a computation in the ? monad with the given @.. In the case of an exceptional situation an  will be thrown.TreqGiven host name, produce a ) which has @http@ as its scheme and empty path. This also sets port to 80.UreqGiven host name, produce a ) which has @https@ as its scheme and empty path. This also sets port to 443.Vreq Grow a given ) appending a single path segment to it. Note that the path segment can be of any type that is an instance of .WreqA type-constrained version of (V)< to remove ambiguity in the cases when next URL piece is a  literal.Xreq Render a ) as .YreqThe Y0 function provides an alternative method to get ) (possibly with some  s) from a . This is useful when you are given a URL to query dynamically and don't know it beforehand.This function expects the scheme to be @http@ and host to be present.Zreq Just like Y!, but expects the @https@ scheme. reqConvert URI path to a ) . Internal.[reqA combination of Y and Z0 for cases when scheme is not known in advance.req3An internal helper function to extract host from a .\reqA quasiquoter to build an ) and 1 tuple. The type of the generated expression is () scheme0,  scheme1) with scheme0 being either  or  depending on the input.req'An internal helper function to extract  s from a .]reqCreate # request body from a collection of s.reqA helper to create an  that modifies only collection of query parameters. This helper is not a part of the public API.reqA helper to create an  that modifies only +. This helper is not a part of public API.reqFinalize given ) by applying a finalizer from the given  (if it has any).^reqThis operator builds a query parameter that will be included in URL of your request after the question sign ?. This is the same syntax you use with form URL encoded request bodies.%This operator is defined in terms of : ,name =: value = queryParam name (pure value)_reqConstruct a flag, that is, a valueless query parameter. For example, in the following URL "a" is a flag, while "b"$ is a query parameter with a value: "https://httpbin.org/foo/bar?a&b=10%This operator is defined in terms of : 6queryFlag name = queryParam name (Nothing :: Maybe ())` req"Construct query parameters from a < instance. This function produces the same query params as . Note that  doesn't have the concept of parameters with the empty value (i.e. what you can get by  key =: ""). If the value is empty, it will be encoded as a valueless parameter (i.e. what you can get by  queryFlag key).areq Create an & that adds a header. Note that if you  two headers with the same names the leftmost header will win. This means, in particular, that you cannot create a request with several headers of the same name.breq1Attach a header with given name and content to a .c reqSame as a$, but with redacted values on print.dreqUse the given . A  can be obtained from a  record.ereqThe  adds basic authentication. See also:  9https://en.wikipedia.org/wiki/Basic_access_authentication.freqAn alternative to e which works for any scheme. Note that using basic access authentication without SSL/TLS is vulnerable to attacks. Use e, instead unless you know what you are doing.greqThe ' set basic proxy authentication header.hreqThe  adds OAuth1 authentication.ireqThe  adds an OAuth2 bearer token. This is treated by many services as the equivalent of a username and password.The  is defined as: oAuth2Bearer token = header "Authorization" ("Bearer " <> token) See also:  #https://en.wikipedia.org/wiki/OAuth.jreqThe  adds a not-quite-standard OAuth2 bearer token (that seems to be used only by GitHub). This will be treated by whatever services accept it as the equivalent of a username and password.The  is defined as: =oAuth2Token token = header "Authorization" ("token" <> token) See also:  https://developer.github.com/v3/oauth#3-use-the-access-token-to-access-the-api.kreq)A helper to create custom authentication s. The given -enabled request transformation is applied after all other modifications when constructing a request. Use wisely.lreq5Specify the port to connect to explicitly. Normally, )' you use determines the default port: 80 for HTTP and 443 for HTTPS. This  allows us to choose an arbitrary port overwriting the defaults.mreqThis  controls whether gzipped data should be decompressed on the fly. By default everything except for "application/x-tar" is decompressed, i.e. we have: #decompress (/= "application/x-tar")7You can also choose to decompress everything like this: decompress (const True)nreqSpecify the number of microseconds to wait for response. The default value is 30 seconds (defined in  of connection ).oreq;<9:78563412/0-.*+,)TUVWYZ[\X'(%&#$!" ]^_`abcdefghijklmnopqrstuvwx yMNOPQJLK@AHFGIEBCDR?S=>;<9:78563412/0-.*+,)TUVWYZ[\X'(%&#$!" ]^_`abcdefghijklmnopqrstuvwx yV5W5^7       !"#$$%%&&''(())*+,-..//001122334455667889:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ !req-3.13.2-JsMUQzICZA2CFcrtKYvuW6Network.HTTP.ReqreqControl.Monad.Except MonadError throwErrorControl.Monad.Reader MonadReaderSchemeHttpHttps CanHaveBodyNoBody HttpExceptionVanillaHttpExceptionJsonHttpException HttpResponseHttpResponseBodytoVanillaResponsegetHttpResponse acceptHeader LbsResponse BsResponse JsonResponseIgnoreResponse QueryParam queryParamqueryParamToListOptionHttpBodyAllowed ProvidesBodyHttpBodygetRequestBodygetRequestContentTypeReqBodyMultipartFormUrlEncodedParam ReqBodyUrlEnc ReqBodyLbs ReqBodyBs ReqBodyFile ReqBodyJson NoReqBodyUrl HttpMethod AllowsBodyhttpMethodNamePATCHOPTIONSCONNECTTRACEDELETEPUTHEADPOSTGETReq HttpConfighttpConfigProxyhttpConfigRedirectCounthttpConfigAltManagerhttpConfigCheckResponsehttpConfigRetryPolicyhttpConfigRetryJudgehttpConfigRetryJudgeExceptionhttpConfigBodyPreviewLength MonadHttphandleHttpException getHttpConfigreqBrreqCbreq'withReqManagerdefaultHttpConfigrunReqhttphttps/~/: renderUrl useHttpURI useHttpsURIuseURIurlQreqBodyMultipart=: queryFlag formToQueryheader attachHeaderheaderRedacted cookieJar basicAuthbasicAuthUnsafebasicProxyAuthoAuth1 oAuth2Bearer oAuth2Token customAuthport decompressresponseTimeout httpVersionignoreResponse jsonResponse bsResponse lbsResponse responseBodyresponseStatusCoderesponseStatusMessageresponseHeaderresponseCookieJarisStatusCodeException$fMonadBaseControlIOReq$fMonadBaseIOReq$fFromFormFormUrlEncodedParam$fHttpBodyReqBodyMultipart$fHttpBodyReqBodyUrlEnc$fHttpBodyReqBodyLbs$fHttpBodyReqBodyBs$fHttpBodyReqBodyFile$fHttpBodyReqBodyJson$fHttpBodyNoReqBody$fQueryParamFormUrlEncodedParam$fHttpResponseResponse$fHttpResponseLbsResponse$fHttpResponseBsResponse$fHttpResponseIgnoreResponse$fRequestComponentHttpConfig$fRequestComponentTagged$fExceptionHttpException$fHttpResponseJsonResponse$fMonadHttpWriterT$fMonadHttpWriterT0$fMonadHttpWriterT1$fMonadHttpStateT$fMonadHttpStateT0$fMonadHttpSelectT$fMonadHttpRWST$fMonadHttpRWST0$fMonadHttpRWST1$fMonadHttpReaderT$fMonadHttpMaybeT$fMonadHttpIdentityT$fMonadHttpExceptT$fMonadHttpContT$fMonadHttpAccumT$fMonadHttpReq$fRequestComponentTagged0$fHttpMethodTYPEPATCH$fHttpMethodTYPEOPTIONS$fHttpMethodTYPECONNECT$fHttpMethodTYPETRACE$fHttpMethodTYPEDELETE$fHttpMethodTYPEPUT$fHttpMethodTYPEHEAD$fHttpMethodTYPEPOST$fHttpMethodTYPEGET$fQueryParamOption$fRequestComponentOption$fFromFormOption$fMonoidOption$fSemigroupOption$fRequestComponentUrl$fLiftBoxedRepUrl$fEqUrl$fOrdUrl $fShowUrl $fDataUrl $fGenericUrl $fEqScheme $fOrdScheme $fShowScheme $fDataScheme$fGenericScheme$fLiftBoxedRepScheme$fShowHttpException$fGenericHttpException$fShowLbsResponse$fShowBsResponse$fShowJsonResponse$fShowIgnoreResponse$fSemigroupFormUrlEncodedParam$fMonoidFormUrlEncodedParam $fFunctorReq$fApplicativeReq $fMonadReq $fMonadIOReq$fMonadUnliftIOReq$fMonadMaskReq$fMonadCatchReq$fMonadThrowReqghc-prim GHC.TypesBool)http-client-0.7.16-AWeDs181duv2MX9bCXr6kLNetwork.HTTP.Client.TypesbaseGHC.BaseStringTaggedRequestComponentRequestData.Semigroup.InternalEndo<> getRequestModResponse BodyReaderIObytestring-0.11.5.2Data.ByteString.Internal.Type ByteStringData.ByteString.Lazy.Internal GHC.MaybeNothingMonoid RequestBody$aeson-2.2.1.0-1z8UUFvsnm0KblTgG0j8M3Data.Aeson.Types.ToJSONToJSONManagerHttpExceptionContentJust$retry-0.9.3.1-2akCmEy9O8D3sLw7cwj4Fo Control.Retry RetryPolicyMTruemempty reqHandler globalManager GHC.IO.UnsafeunsafePerformIO GHC.IORefIORef(http-api-data-0.6-DnOOhUYOJst1frLe13A6zLWeb.Internal.HttpApiData ToHttpApiData text-2.0.2Data.Text.InternalText GHC.TypeError ErrorMessage)modern-uri-0.3.6.1-8qKFGUHwrZB7nWREWaUpi1Text.URI.TypesURI uriPathToUrluriHost uriOptions%Network.HTTP.Client.MultipartFormDataPartwithQueryParams withRequestfinalizeRequestWeb.Internal.FormUrlEncodedToFormurlEncodeAsFormStableFormmappend CookieJarManagerSettings grabPreviewbrReadNStatusCodeException