úÎ!…hyä§      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦© 2016 present Mark Karpov BSD 3 clause$Mark Karpov <markkarpov92@gmail.com> experimentalportableNone"#.27:=?@AHIMSVX_vnreqA 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 failedªreqpThis 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 H method of G3 instance corresponding to monad in which you use J@ 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 (Y) and Z: 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 X0 to create actual request body from the parts. X- 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 .reqÿJForm 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: (Y) and Z.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.$req˜This 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 P or Q@ specifying the scheme and host at the same time. Then use the (R) and (S)t operators to grow the path one piece at a time. Every single piece of path will be url(percent)-encoded, so using (R) and (S)´ 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.4req4A method. This data type does not allow having request body with 49 requests, as it should be. However some APIs may expect 4F requests to have bodies, in that case define your own variation of 4$ method and allow it to have a body.6req6 method.8req8 method.:req: method.<req< method.>reqA monad that allows to run J 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 H.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.GreqgA type class for monads that support performing HTTP requests. Typically, you only need to define the H" method unless you want to tweak ?.Hreq'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 .IreqReturn ?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 I@ is to return some hard-coded value, or a value extracted from ¾< if a more flexible approach to configuration is desirable.JreqlMake 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:ijk (to get a strict ³)l (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 JV 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)Kreq A version of J7 that does not use one of the predefined instances of  ( but instead allows the user to consume ° ± manually, in a custom way.Lreq Mostly like Jn 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.Mreq,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 J— 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 I.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.NreqDefault value of ?.OreqRun a computation in the > monad with the given ?'. In case of exceptional situation an  will be thrown.PreqGiven host name, produce a (H which has http  as its scheme and empty path. This also sets port to 80.QreqGiven host name, produce a (I which has https  as its scheme and empty path. This also sets port to 443.Rreq 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 Ã.SreqType-constrained version of (R)< to remove ambiguity in the cases when next URL piece is a Ä literal.TreqThe T0 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.Ureq Just like T!, but expects the https  scheme.VreqA combination of T and U0 for cases when scheme is not known in advance.Æreq3An internal helper function to extract host from a Å.WreqA 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 Å.XreqCreate # 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).YreqmThis 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)ZreqYConstruct 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 ¬.]reqUse the given Í. A Í can be obtained from a ° record.^reqThe  adds basic authentication. See also:  9https://en.wikipedia.org/wiki/Basic_access_authentication._reqAn alternative to ^y which works for any scheme. Note that using basic access authentication without SSL/TLS is vulnerable to attacks. Use ^, instead unless you know what you are doing.`reqThe ' set basic proxy authentication header.areqThe  adds OAuth1 authentication.breqThe 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.creqThe º 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.dreq)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.ereq5Specify 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.freqThis 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)greqfSpecify the number of microseconds to wait for response. The default value is 30 seconds (defined in Î of connection ¹).hreq<HTTP version to send to the server, the default is HTTP 1.1.ireq#Use this as the fourth argument of J: to specify that you want it to ignore the response body.jreq#Use this as the fourth argument of J, to specify that you want it to return the  interpretation.kreq#Use this as the fourth argument of JF to specify that you want to interpret the response body as a strict ³.lreq#Use this as the fourth argument of JD 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.mreqGet the response body.nreqGet the response status code.oreq Get the response status message.preq+Lookup a particular header from a response.qreqGet the response Í.Ñreq0Max length of preview fragment of response body. req Response with body reader insidereqThe final resultJreq HTTP methodreq( location of resourcereqBody of the requestreq A hint how to interpret responsereq!Collection of optional parametersreqResponseKreq HTTP methodreq( location of resourcereqBody of the requestreq!Collection of optional parametersreqHow to consume responsereqResultLreq HTTP methodreq( location of resourcereqBody of the requestreq!Collection of optional parametersreqHow to perform requestreqResultOreq? to usereqComputation to run[req Header namereq Header value^reqUsernamereqPasswordreqAuth _reqUsernamereqPasswordreqAuth `reqUsernamereqPasswordreqAuth areqConsumer tokenreqConsumer secretreq OAuth tokenreqOAuth token secretreqAuth breqTokenreqAuth creqTokenreqAuth freq/Predicate that is given MIME type, it returns ½0 when content should be decompressed on the fly.greqNumber of microseconds to waithreqMajor version numberreqMinor version numberÏreqHow many bytes to fetchreq Response with body reader insidereqPreview ³) and new response with body reader insideÐreqBody reader to stream fromreqHow many bytes to consumereq.Target chunk, the leftover, whether we're donepreqResponse interpretationreqHeader to lookupreqHeader value if foundr  !"#$%&'()*+,-./0123456789:;<=>?@EFDABCGIHJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrJKLMGIH?@EFDABCN>O<=:;8967452301./,-)*+(PQRSTUVW&'$%"# !XYZ[\]^_`abcdefghijklmnopq R5S5Y7Ò       !!""##$$%%&'()**++,,--..//00112234456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ  ¡¢£¤žŸ¥ ¦§ ¡¨©žŸªžŸ«›œ¬­®¯­°¯ ±² ¡³žŸ´µ¶·žŸ¸žŸ¹ ±º»¼½›œ¾¿ÀÁ ¡ÂàÄÅ ÆÇÈÉÊËÌÍÎÏÐÑÒžÓÔÕÖ× ¡ØžŸÙžŸÚÛÜÝÞ req-3.2.0-JhUsydwQjqd3Ls5oLpfp8gNetwork.HTTP.ReqControl.Monad.Except MonadError throwErrorSchemeHttpHttps CanHaveBodyNoBody HttpExceptionVanillaHttpExceptionJsonHttpException HttpResponseHttpResponseBodytoVanillaResponsegetHttpResponse acceptHeader LbsResponse BsResponse JsonResponseIgnoreResponse QueryParam queryParamOptionHttpBodyAllowed ProvidesBodyHttpBodygetRequestBodygetRequestContentTypeReqBodyMultipartFormUrlEncodedParam ReqBodyUrlEnc ReqBodyLbs ReqBodyBs ReqBodyFile ReqBodyJson NoReqBodyUrl HttpMethod AllowsBodyhttpMethodNamePATCHOPTIONSCONNECTTRACEDELETEPUTHEADPOSTGETReq HttpConfighttpConfigProxyhttpConfigRedirectCounthttpConfigAltManagerhttpConfigCheckResponsehttpConfigRetryPolicyhttpConfigRetryJudge MonadHttphandleHttpException getHttpConfigreqreqBrreq'withReqManagerdefaultHttpConfigrunReqhttphttps/~/: 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$fSemigroupFormUrlEncodedParam$fMonoidFormUrlEncodedParam$fShowHttpException$fGenericHttpException $fEqScheme $fOrdScheme $fShowScheme $fDataScheme$fGenericScheme $fLiftScheme$fEqUrl$fOrdUrl $fShowUrl $fDataUrl $fGenericUrlghc-prim GHC.TypesBool(http-client-0.7.0-IwHozNUPXmL6nQA4sx8i7kNetwork.HTTP.Client.TypesbaseGHC.BaseStringWombRequestComponentRequestData.Semigroup.InternalEndo<> getRequestModResponse BodyReaderIObytestring-0.10.8.2Data.ByteString.Internal ByteStringData.ByteString.Lazy.Internal GHC.MaybeNothingMonoid RequestBody$aeson-1.5.1.0-HC4HMiStOKwE0P6LBhMbVZData.Aeson.Types.ToJSONToJSONManagerHttpExceptionContentJust$retry-0.8.1.2-HmOlrehu09M3GKTnDDCGfj Control.Retry RetryPolicyMTrue mtl-2.2.2Control.Monad.Reader.Class MonadReadermempty globalManager GHC.IO.UnsafeunsafePerformIO GHC.IORefIORef,http-api-data-0.4.1.1-57ULSmqUyGILq8oiRLWLWqWeb.Internal.HttpApiData ToHttpApiData text-1.2.3.1Data.Text.InternalText)modern-uri-0.3.2.0-4yFUevs4AnmBjFCWnMf3rPText.URI.TypesURIuriHost uriOptions%Network.HTTP.Client.MultipartFormDataPartwithQueryParams withRequestfinalizeRequestmappend CookieJarManagerSettings grabPreviewbrReadNbodyPreviewLength