!qt3      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ 2016 2018 Mark Karpov BSD 3 clause$Mark Karpov <markkarpov92@gmail.com> experimentalportableNone"#-16;=>?FKQTVp~jreqA 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. 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 G method of F3 instance corresponding to monad in which you use I@ 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 (V) and W: 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 user to use % with ;6 method and other methods that should not send a body.req<A type class for things that can be interpreted as an HTTP .reqHow to get actual .req2This method allows to optionally specify value of  Content-TypeQ 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 U0 to create actual request body from the parts. U- 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: (V) and W.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 N or O@ specifying the scheme and host at the same time. Then use the (P) and (Q)t operators to grow the path one piece at a time. Every single piece of path will be url(percent)-encoded, so using (P) and (Q) 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 j which tells the rest of the library whether the method can have a 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./req/ method.1req1 method.3req3A method. This data type does not allow having request body with 39 requests, as it should be. However some APIs may expect 3F requests to have bodies, in that case define your own variation of 3$ method and allow it to have a body.5req5 method.7req7 method.9req9 method.;req; method.=reqA monad that allows to run I 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.@req#Proxy to use. By default values of  HTTP_PROXY and  HTTPS_PROXYU environment variables are respected, this setting overwrites them. Default value: .AreqIHow many redirects to follow when getting a resource. Default value: 10.Breq Alternative  to use. o (default value) means that the default implicit manager will be used (that's what you want in 99% of cases).Creq!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 G.Note9: signature of this function was changed in the version 1.0.0.Dreq9The retry policy to use for request retrying. By default  is used (see ).Note9: signature of this function was changed in the version 1.0.0.Ereq;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.FreqgA type class for monads that support performing HTTP requests. Typically, you only need to define the G" method unless you want to tweak >.Greq'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 .HreqReturn >O to be used when performing HTTP requests. Default implementation returns its k value, which is described in the documentation for the type. Common usage pattern with manually defined H@ is to return some hard-coded value, or a value extracted from < if a more flexible approach to configuration is desirable.IreqlMake 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 9F. 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:fgh (to get a strict )i (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 IV 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: C{-# LANGUAGE OverloadedStrings #-} module Main (main) where import Control.Monad import Control.Monad.IO.Class import Data.Aeson import Data.Default.Class 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'We will be making requests against the  https://httpbin.org service.(Make a GET request, grab 5 random bytes: main :: IO () main = runReq def $ 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 def $ 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: udata MyData = MyData { size :: Int , color :: Text } deriving (Show, Generic) instance ToJSON MyData instance FromJSON MyData main :: IO () main = runReq def $ 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 def $ 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: Wmain :: IO () main = runReq def $ 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'. let (url, options) = fromJust (parseUrlHttps "https://httpbin.org/get?foo=bar") 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)Jreq A version of I7 that does not use one of the predefined instances of  ( but instead allows the user to consume   manually, in a custom way.Kreq Mostly like In 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 C#), and retrying. It only prepares  and allows you to use it.Lreq,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 I 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 H.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.MreqRun a computation in the = monad with the given >'. In case of exceptional situation an  will be thrown.NreqGiven host name, produce a 'I which have http  as its scheme and empty path. This also sets port to 80.OreqGiven host name, produce a 'J which have https  as its scheme and empty path. This also sets port to 443.Preq 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 .QreqType-constrained version of (P)< to remove ambiguity in the cases when next URL piece is a  literal.RreqThe R0 function provides an alternative method to get ' (possibly with some  s) from a s. This is useful when you are given a URL to query dynamically and don't know it beforehand. The function parses 7 because it's the correct type to represent a URL, as '[ cannot contain characters outside of ASCII range, thus we can consider every character a  value.This function only parses 'J (scheme, host, path) and optional query parameters that are returned as C. It does not parse method name or authentication info from given .Sreq Just like R, but expects https  scheme.TreqZA more general URI parsing function that can be used when scheme is not known beforehand.reqWGet host/collection of path pieces and possibly query parameters already converted to . This function is not public.UreqCreate # 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).VreqmThis 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)WreqYConstruct 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 ())Xreq 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.YreqMA non-public helper that attaches a header with given name and content to a .ZreqUse 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.^reqThe  adds OAuth1 authentication._reqThe 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.`reqThe  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.areq)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.breq5Specify 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.creqThis 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)dreqfSpecify the number of microseconds to wait for response. The default value is 30 seconds (defined in  of connection ).ereq<HTTP version to send to the server, the default is HTTP 1.1.freq#Use this as the fourth argument of I: to specify that you want it to ignore the response body.greq#Use this as the fourth argument of I, to specify that you want it to return the  interpretation.hreq#Use this as the fourth argument of IF to specify that you want to interpret the response body as a strict .ireq#Use this as the fourth argument of ID 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.jreqGet the response body.kreqGet the response status code.lreq Get the response status message.mreq+Lookup a particular header from a response.nreqGet the response .req0Max length of preview fragment of response body. req Response with body reader insidereqThe final resultIreq HTTP methodreq' location of resourcereqBody of the requestreq A hint how to interpret responsereq!Collection of optional parametersreqResponseJreq HTTP methodreq' location of resourcereqBody of the requestreq!Collection of optional parametersreqHow to consume responsereqResultKreq HTTP methodreq' location of resourcereqBody of the requestreq!Collection of optional parametersreqHow to perform requestreqResultMreq> to usereqComputation to runXreq Header namereq Header value[reqUsernamereqPasswordreqAuth \reqUsernamereqPasswordreqAuth ]reqUsernamereqPasswordreqAuth ^reqConsumer tokenreqConsumer secretreq OAuth tokenreqOAuth token secretreqAuth _reqTokenreqAuth `reqTokenreqAuth creq/Predicate that is given MIME type, it returns 0 when content should be decompressed on the fly.dreqNumber of microseconds to waitereqMajor 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 donemreqResponse interpretationreqHeader to lookupreqHeader value if foundo  !"#$%&'()*+,-./0123456789:;<=>?DEC@ABFHGIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnoIJKLFHG>?DEC@AB=M;<9:78563412/0-.+,()*'NOPQRST%&#$!" UVWXYZ[\]^_`abcdefgh ijklmn P5Q5V7       !!""##$$%%&&'()*++,,--..//001122334556789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~  req-1.2.1-2ZNra7NBTX310ujzUgQWEdNetwork.HTTP.ReqControl.Monad.Except MonadError throwError Data.WordWord8SchemeHttpHttps CanHaveBodyNoBody HttpExceptionVanillaHttpExceptionJsonHttpException HttpResponseHttpResponseBodytoVanillaResponsegetHttpResponse LbsResponse BsResponse JsonResponseIgnoreResponse QueryParam queryParamOptionHttpBodyAllowed ProvidesBodyHttpBodygetRequestBodygetRequestContentTypeReqBodyMultipartFormUrlEncodedParam ReqBodyUrlEnc ReqBodyLbs ReqBodyBs ReqBodyFile ReqBodyJson NoReqBodyUrl HttpMethod AllowsBodyhttpMethodNamePATCHOPTIONSCONNECTTRACEDELETEPUTHEADPOSTGETReq HttpConfighttpConfigProxyhttpConfigRedirectCounthttpConfigAltManagerhttpConfigCheckResponsehttpConfigRetryPolicyhttpConfigRetryJudge MonadHttphandleHttpException getHttpConfigreqreqBrreq'withReqManagerrunReqhttphttps/~/: parseUrlHttp parseUrlHttpsparseUrlreqBodyMultipart=: queryFlagheader attachHeader cookieJar basicAuthbasicAuthUnsafebasicProxyAuthoAuth1 oAuth2Bearer oAuth2Token customAuthport decompressresponseTimeout httpVersionignoreResponse jsonResponse bsResponse lbsResponse responseBodyresponseStatusCoderesponseStatusMessageresponseHeaderresponseCookieJar$fDefaultHttpConfig$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 $fFunctorReq$fApplicativeReq $fMonadReq $fMonadIOReq$fSemigroupFormUrlEncodedParam$fMonoidFormUrlEncodedParam$fShowHttpException$fGenericHttpException $fEqScheme $fOrdScheme $fShowScheme $fDataScheme$fGenericScheme$fEqUrl$fOrdUrl $fShowUrl $fDataUrl $fGenericUrlghc-prim GHC.TypesBool+http-client-0.5.13.1-7XwOo5LOPAZFWAPa1Lp1nWNetwork.HTTP.Client.TypesbaseGHC.BaseStringWombRequestComponentRequestData.Semigroup.InternalEndo<> getRequestModResponse BodyReaderIObytestring-0.10.8.2Data.ByteString.Internal ByteStringData.ByteString.Lazy.InternalNothingMonoid RequestBody$aeson-1.4.0.0-LIOMjdhUbDoEPhbHMMZ6tyData.Aeson.Types.ToJSONToJSONManagerHttpExceptionContentJust1data-default-class-0.1.2.0-2kYzERBLX3wJoPfj7mwVvWData.Default.Classdef$retry-0.7.6.2-A1nuJrQ8ZMv2ArqnXGUdST Control.Retry RetryPolicyMTrue mtl-2.2.2Control.Monad.Reader.Class MonadReadermempty globalManager GHC.IO.UnsafeunsafePerformIO GHC.IORefIORef,http-api-data-0.3.8.1-8JbdzYMkghw4VmWZ8qnnFMWeb.Internal.HttpApiData ToHttpApiData text-1.2.3.0Data.Text.InternalTextparseUrlHelper%Network.HTTP.Client.MultipartFormDataPartwithQueryParams withRequestfinalizeRequestmappend CookieJarManagerSettings grabPreviewbrReadNbodyPreviewLength