!ȳ      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ 2016 present Mark Karpov BSD 3 clause$Mark Karpov <markkarpov92@gmail.com> experimentalportableNone"#.127:=?@AHIMSVX_ureqA 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 q 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 failedreqpThis 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. p 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. reqaA type class for response interpretations. It allows to describe how to consume response from a  B and produce the final result that is to be returned to the user. reqSThe 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. reqPThis method describes how to consume response body and, more generally, obtain response value from  .Note:  is nothing but  D. 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"B 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.reqAMake a request and interpret the body of the response as a lazy .reqCMake a request and interpret the body of the response as a strict .reqDMake a request and interpret the body of the response as JSON. The J method of I3 instance corresponding to monad in which you use L@ 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.reqPA 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.reqACreate a query parameter with given name and value. If value is Z, 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.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 &.Note: users of GHC 8.0.1 and later will see a slightly more friendly error message when method does not allow a body and body is provided.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<A type class for things that can be interpreted as an HTTP .reqHow to get actual .req:This method allows us to optionally specify the value of  Content-TypeP header that should be used with particular body option. By default it returns  and so  Content-Type is not set.req)Multipart form data. Please consult the %Network.HTTP.Client.MultipartFormData. module for how to construct parts, then use \0 to create actual request body from the parts. \- is the only way to get a value of the type 0, as its constructor is not exported on purpose.Examples import Control.Monad.IO.Class import Data.Default.Class import Network.HTTP.Req import qualified Network.HTTP.Client.MultipartFormData as LM main :: IO () main = runReq def $ do body <- reqBodyMultipart [ LM.partBS "title" "My Image" , LM.partFileSource "file1" "/tmp/image.jpg" ] response <- req POST (http "example.com" /: "post") body bsResponse mempty liftIO $ print (responseBody response)reqYAn opaque monoidal value that allows to collect URL-encoded parameters to be wrapped in .reqJForm URL-encoded body. This can hold a collection of parameters which are encoded similarly to query parameters at the end of query string, with the only difference that they are stored in request body. The similarity is reflected in the API as well, as you can use the same combinators you would use to add query parameters: (]) and ^.This body option sets the  Content-Type header to #"application/x-www-form-urlencoded" value.req(HTTP request body represented by a lazy .+Using of this body option does not set the  Content-Type header. req*HTTP request body represented by a strict .+Using of this body option does not set the  Content-Type header."req{This body option streams request body from a file. It is expected that the file size does not change during the streaming.+Using of this body option does not set the  Content-Type header.$reqThis body option allows to use a JSON object as request body probably the most popular format right now. Just wrap a data type that is an instance of Y type class and you are done: it will be converted to JSON and inserted as request body.This body option sets the  Content-Type header to ""application/json; charset=utf-8" value.&req\This data type represents empty body of an HTTP request. This is the data type to use with )<s that cannot have a body, as it's the only type for which  returns .+Using of this body option does not set the  Content-Type header.(req Request's (. Start constructing your ( with S or T@ specifying the scheme and host at the same time. Then use the (U) and (V)t operators to grow the path one piece at a time. Every single piece of path will be url(percent)-encoded, so using (U) and (V) is the only way to have forward slashes between path segments. This approach makes working with dynamic path segments easy and safe. See examples below how to represent various (s (make sure the OverloadedStrings language extension is enabled).Examples (http "httpbin.org" -- http://httpbin.org *https "httpbin.org" -- https://httpbin.org Phttps "httpbin.org" /: "encoding" /: "utf8" -- https://httpbin.org/encoding/utf8 Nhttps "httpbin.org" /: "foo" /: "bar/baz" -- https://httpbin.org/foo/bar%2Fbaz Mhttps "httpbin.org" /: "bytes" /~ (10 :: Int) -- https://httpbin.org/bytes/10 Nhttps "N=8:>4.@D" -- https://%D1%8E%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4.%D1%80%D1%84)req~A type class for types that can be used as an HTTP method. To define a non-standard method, follow this example that defines COPY: vdata COPY = COPY instance HttpMethod COPY where type AllowsBody COPY = 'CanHaveBody httpMethodName Proxy = "COPY"*reqType function * returns a type of kind h which tells the rest of the library whether the method can have body or not. We use the special type & lifted to the kind level instead of - to get more user-friendly compiler messages.+reqReturn name of the method as a .,req, method..req. method.0req0 method.2req2 method.4req4D method. RFC 7231 allows a payload in DELETE but without semantics.Note: before version 3.4.0+ this method did not allow request bodies.6req6 method.8req8 method.:req: method.<req< method.>reqA monad that allows to run L in any 7-enabled monad without having to define new instances.?req?M contains general and default settings to be used when making HTTP requests.Areq#Proxy to use. By default values of  HTTP_PROXY and  HTTPS_PROXYU environment variables are respected, this setting overwrites them. Default value: .BreqIHow many redirects to follow when getting a resource. Default value: 10.Creq Alternative  to use. o (default value) means that the default implicit manager will be used (that's what you want in 99% of cases).Dreq!Function to check the response immediately after receiving the status and headers, before streaming of response body. The third argument is the beginning of response body (typically first 1024 bytes). This is used for throwing exceptions on non-success status codes by default (set to \_ _ _ -> 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.xThrowing 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 J.Note9: signature of this function was changed in the version 1.0.0.Ereq9The retry policy to use for request retrying. By default def is used (see ).Note9: signature of this function was changed in the version 1.0.0.Freq;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.Greq Similar to FN, but is used to decide when to retry requests that resulted in an exception.Hreq0Max length of preview fragment of response body.IreqgA type class for monads that support performing HTTP requests. Typically, you only need to define the J" method unless you want to tweak ?.Jreq'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 .KreqReturn ?O to be used when performing HTTP requests. Default implementation returns its defk value, which is described in the documentation for the type. Common usage pattern with manually defined K@ is to return some hard-coded value, or a value extracted from < if a more flexible approach to configuration is desirable.LreqlMake 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 :F. 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 below.responseo is a type hint how to make and interpret response of an HTTP request. Out-of-the-box it can be the following:mno (to get a strict )p (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 LV to do all your requests, connection sharing and reuse is done for you automatically.3See the examples below to get on the speed quickly.Examples[First, this is a piece of boilerplate that should be in place before you try the examples: m{-# 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)GUsing various optional parameters and URL that is not known in advance: zmain :: 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)Mreq A version of L7 that does not use one of the predefined instances of  ( but instead allows the user to consume   manually, in a custom way.Nreq A version of L% that takes a callback to modify the 2, but otherwise performs the request identically.reqNThe default handler function that the higher-level request functions pass to O. Internal function.Oreq Mostly like Ln 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 D#), and retrying. It only prepares  and allows you to use it.Preq,Perform an action using the global implicit P that the rest of the library uses. This allows to reuse connections that the  controls.reqGlobal  that L 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 K.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.QreqDefault value of ?.RreqRun a computation in the > monad with the given ?'. In case of exceptional situation an  will be thrown.SreqGiven host name, produce a (H which has http  as its scheme and empty path. This also sets port to 80.TreqGiven host name, produce a (I which has https  as its scheme and empty path. This also sets port to 443.Ureq Grow given (n appending a single path segment to it. Note that the path segment can be of any type that is an instance of .VreqType-constrained version of (U)< to remove ambiguity in the cases when next URL piece is a  literal.Wreq Render a ( as .XreqThe X0 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.EThis function expects the scheme to be http  and host to be present.Yreq Just like X!, but expects the https  scheme.ZreqA combination of X and Y0 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 a 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).]reqmThis operator builds a query parameter that will be included in URL of your request after the question sign ?H. 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)^reqYConstruct a flag, that is, 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 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.`req1Attach a header with given name and content to a .areqUse the given . A  can be obtained from a  record.breqThe  adds basic authentication. See also:  9https://en.wikipedia.org/wiki/Basic_access_authentication.creqAn alternative to by which works for any scheme. Note that using basic access authentication without SSL/TLS is vulnerable to attacks. Use b, instead unless you know what you are doing.dreqThe ' set basic proxy authentication header.ereqThe  adds OAuth1 authentication.freqThe m 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.greqThe  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:  Nhttps://developer.github.com/v3/oauth#3-use-the-access-token-to-access-the-api.hreq)A helper to create custom authentication s. The given r-enabled request transformation is applied after all other modifications when constructing a request. Use wisely.ireq5Specify the port to connect to explicitly. Normally, (' you use determines the default port: 80 for HTTP and 443 for HTTPS. This = allows to choose an arbitrary port overwriting the defaults.jreqThis d 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)kreqfSpecify the number of microseconds to wait for response. The default value is 30 seconds (defined in  of connection ).lreq<HTTP version to send to the server, the default is HTTP 1.1.mreq#Use this as the fourth argument of L: to specify that you want it to ignore the response body.nreq#Use this as the fourth argument of L, to specify that you want it to return the  interpretation.oreq#Use this as the fourth argument of LF to specify that you want to interpret the response body as a strict .preq#Use this as the fourth argument of LD to specify that you want to interpret the response body as a lazy .req=Fetch beginning of response and return it together with new   that can be passed to   and such.reqConsume N bytes from c, return the target chunk, the leftover (may be empty), and whether we're done consuming the body.qreqGet the response body.rreqGet the response status code.sreq Get the response status message.treq+Lookup a particular header from a response.ureqGet the response .reqreqreq req Response with body reader insidereqThe final resultLreq HTTP methodreq( location of resourcereqBody of the requestreq A hint how to interpret responsereq!Collection of optional parametersreqResponseMreq HTTP methodreq( location of resourcereqBody of the requestreq!Collection of optional parametersreqHow to consume responsereqResultNreq HTTP methodreq( location of resourcereqBody of the requestreq A hint how to interpret responsereq!Collection of optional parametersreqCallback to modify the requestreqResponsereqHow to get final result from a req to performreq to useOreq HTTP methodreq( location of resourcereqBody of the requestreq!Collection of optional parametersreqHow to perform requestreqResultRreq? to usereqComputation to run_req Header namereq Header valuebreqUsernamereqPasswordreqAuth creqUsernamereqPasswordreqAuth dreqUsernamereqPasswordreqAuth ereqConsumer tokenreqConsumer secretreq OAuth tokenreqOAuth token secretreqAuth freqTokenreqAuth greqTokenreqAuth jreq/Predicate that is given MIME type, it returns 0 when content should be decompressed on the fly.kreqNumber of microseconds to waitlreqMajor version numberreqMinor version numberreqHow many bytes to fetchreq Response with body reader insidereqPreview ) and new response with body reader insidereqBody reader to stream fromreqHow many bytes to consumereq.Target chunk, the leftover, whether we're donetreqResponse interpretationreqHeader to lookupreqHeader value if foundv  !"#$%&'()*+,-./0123456789:;<=>?@GEFHDABCIKJLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvLMNOPIKJ?@GEFHDABCQ>R<=:;8967452301./,-)*+(STUVXYZ[W&'$%"# !\]^_`abcdefghijklmnopqrstu U5V5]7       !!""##$$%%&'()**++,,--..//00112234456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~  req-3.7.0-79a046cm2bO4MaSTXN1VE2Network.HTTP.ReqControl.Monad.Except MonadError throwErrorSchemeHttpHttps CanHaveBodyNoBody HttpExceptionVanillaHttpExceptionJsonHttpException HttpResponseHttpResponseBodytoVanillaResponsegetHttpResponse acceptHeader LbsResponse BsResponse JsonResponseIgnoreResponse QueryParam queryParamOptionHttpBodyAllowed ProvidesBodyHttpBodygetRequestBodygetRequestContentTypeReqBodyMultipartFormUrlEncodedParam ReqBodyUrlEnc ReqBodyLbs ReqBodyBs ReqBodyFile ReqBodyJson NoReqBodyUrl HttpMethod AllowsBodyhttpMethodNamePATCHOPTIONSCONNECTTRACEDELETEPUTHEADPOSTGETReq HttpConfighttpConfigProxyhttpConfigRedirectCounthttpConfigAltManagerhttpConfigCheckResponsehttpConfigRetryPolicyhttpConfigRetryJudgehttpConfigRetryJudgeExceptionhttpConfigBodyPreviewLength MonadHttphandleHttpException getHttpConfigreqreqBrreqCbreq'withReqManagerdefaultHttpConfigrunReqhttphttps/~/: renderUrl useHttpURI useHttpsURIuseURIurlQreqBodyMultipart=: queryFlagheader attachHeader cookieJar basicAuthbasicAuthUnsafebasicProxyAuthoAuth1 oAuth2Bearer oAuth2Token customAuthport decompressresponseTimeout httpVersionignoreResponse jsonResponse bsResponse lbsResponse responseBodyresponseStatusCoderesponseStatusMessageresponseHeaderresponseCookieJar$fMonadBaseControlIOReq$fMonadBaseIOReq$fHttpBodyReqBodyMultipart$fHttpBodyReqBodyUrlEnc$fHttpBodyReqBodyLbs$fHttpBodyReqBodyBs$fHttpBodyReqBodyFile$fHttpBodyReqBodyJson$fHttpBodyNoReqBody$fQueryParamFormUrlEncodedParam$fHttpResponseLbsResponse$fHttpResponseBsResponse$fHttpResponseIgnoreResponse$fRequestComponentHttpConfig$fRequestComponentWomb$fExceptionHttpException$fHttpResponseJsonResponse$fMonadHttpReq$fRequestComponentWomb0$fHttpMethodPATCH$fHttpMethodOPTIONS$fHttpMethodCONNECT$fHttpMethodTRACE$fHttpMethodDELETE$fHttpMethodPUT$fHttpMethodHEAD$fHttpMethodPOST$fHttpMethodGET$fQueryParamOption$fRequestComponentOption$fMonoidOption$fSemigroupOption$fRequestComponentUrl $fLiftUrl $fFunctorReq$fApplicativeReq $fMonadReq $fMonadIOReq$fMonadUnliftIOReq$fSemigroupFormUrlEncodedParam$fMonoidFormUrlEncodedParam$fShowIgnoreResponse$fShowJsonResponse$fShowBsResponse$fShowLbsResponse$fShowHttpException$fGenericHttpException $fEqScheme $fOrdScheme $fShowScheme $fDataScheme$fGenericScheme $fLiftScheme$fEqUrl$fOrdUrl $fShowUrl $fDataUrl $fGenericUrl$fMonadMaskReq$fMonadCatchReq$fMonadThrowReqghc-prim GHC.TypesBool*http-client-0.7.2.1-CGHOG2GvWNiCFyP5jTtrrlNetwork.HTTP.Client.TypesbaseGHC.BaseStringWombRequestComponentRequestData.Semigroup.InternalEndo<> getRequestModResponse BodyReaderIObytestring-0.10.8.2Data.ByteString.Internal ByteStringData.ByteString.Lazy.Internal GHC.MaybeNothingMonoid RequestBody$aeson-1.5.4.1-3APs9y3MNqVGctYGeZatTtData.Aeson.Types.ToJSONToJSONManagerHttpExceptionContentJust$retry-0.8.1.2-GwO6n6er9Wk3D1cFXdXaGe Control.Retry RetryPolicyMTrue mtl-2.2.2Control.Monad.Reader.Class MonadReadermempty reqHandler globalManager GHC.IO.UnsafeunsafePerformIO GHC.IORefIORef*http-api-data-0.4.2-1mHemQ5RKAWEiJpUGhft1sWeb.Internal.HttpApiData ToHttpApiData text-1.2.3.1Data.Text.InternalText GHC.TypeLits ErrorMessage)modern-uri-0.3.2.0-1YcQIJQNUtn50zibQCTidqText.URI.TypesURIuriHost uriOptions%Network.HTTP.Client.MultipartFormDataPartwithQueryParams withRequestfinalizeRequestmappend CookieJarManagerSettings grabPreviewbrReadN