úÎvøk<¢      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡© 2016 2018 Mark Karpov BSD 3 clause$Mark Karpov <markkarpov92@gmail.com> experimentalportableNone"#-16;=>?FKQTVfiA 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.HTTPHTTPSA 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 .Indeed can have a bodyShould not have a body$Exceptions that this library throws.A wrapper with an £ from Network.HTTP.ClientA wrapper with Aeson-produced € describing why decoding failed¥pThis 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).Š.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.ªGet 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. aA 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. SThe associated type is the type of body that can be extracted from an instance of  . /The method describes how to get the underlying « record. PThis 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. AMake a request and interpret the body of the response as a lazy ¯.CMake a request and interpret the body of the response as a strict ®.DMake 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).3Make a request and ignore the body of the response.PA 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.ACreate 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 (U) and V: instead of this method, because they are easier to read. 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.;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.The 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.<A type class for things that can be interpreted as an HTTP ².How to get actual ².2This 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.)Multipart form data. Please consult the %Network.HTTP.Client.MultipartFormData. module for how to construct parts, then use T0 to create actual request body from the parts. T- 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)YAn opaque monoidal value that allows to collect URL-encoded parameters to be wrapped in .ÿ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: (U) and V.This body option sets the  Content-Type header to #"application/x-www-form-urlencoded" value.(HTTP request body represented by a lazy ¯.+Using of this body option does not set the  Content-Type header.*HTTP request body represented by a strict ®.+Using of this body option does not set the  Content-Type header.!{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.#˜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.%\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.' 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(~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")Type 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.*Return name of the method as a ®.++ method.-- method.// method.11 method.33A 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.55 method.77 method.99 method.;; method.=A monad that allows to run I in any ­7-enabled monad without having to define new instances.>>M contains general and default settings to be used when making HTTP requests.@#Proxy to use. By default values of  HTTP_PROXY and  HTTPS_PROXYU environment variables are respected, this setting overwrites them. Default value: °.AIHow many redirects to follow when getting a resource. Default value: 10.B Alternative Ž to use. °o (default value) means that the default implicit manager will be used (that's what you want in 99% of cases).Cÿ!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.D9The 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.E;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.FgA type class for monads that support performing HTTP requests. Typically, you only need to define the G" method unless you want to tweak >.G'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 .HReturn >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.IlMake 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:efg (to get a strict ®)h (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)J 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.K 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.L,Perform an action using the global implicit ŽP that the rest of the library uses. This allows to reuse connections that the Ž controls.ŒGlobal Ž 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.MRun a computation in the = monad with the given >'. In case of exceptional situation an  will be thrown.NGiven host name, produce a 'I which have http  as its scheme and empty path. This also sets port to 80.OGiven host name, produce a 'J which have https  as its scheme and empty path. This also sets port to 443.P 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 ¿.QType-constrained version of (P)< to remove ambiguity in the cases when next URL piece is a À literal.RThe 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 ®.S Just like R, but expects https  scheme.ÁWGet host/collection of path pieces and possibly query parameters already converted to . This function is not public.TCreate # request body from a collection of Âs.ÃA helper to create an a that modifies only collection of query parameters. This helper is not a part of the public API.ÄA helper to create an  that modifies only §+. This helper is not a part of public API.ÅFinalize given §) by applying a finalizer from the given  (if it has any).UmThis 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)VYConstruct 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 ())W 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.XMA non-public helper that attaches a header with given name and content to a §.YUse the given Ç. A Ç can be obtained from a « record.ZThe  adds basic authentication. See also:  9https://en.wikipedia.org/wiki/Basic_access_authentication.[An alternative to Zy which works for any scheme. Note that using basic access authentication without SSL/TLS is vulnerable to attacks. Use Z, instead unless you know what you are doing.\The ' set basic proxy authentication header.]The  adds OAuth1 authentication.^The 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._The º 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.`)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.a5Specify 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.bThis 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)cfSpecify the number of microseconds to wait for response. The default value is 30 seconds (defined in È of connection Ž).d<HTTP version to send to the server, the default is HTTP 1.1.e#Use this as the fourth argument of I: to specify that you want it to ignore the response body.f#Use this as the fourth argument of I, to specify that you want it to return the  interpretation.g#Use this as the fourth argument of IF to specify that you want to interpret the response body as a strict ®.h#Use this as the fourth argument of ID to specify that you want to interpret the response body as a lazy ¯.É=Fetch beginning of response and return it together with new « ¬ that can be passed to   and such.ÊConsume N bytes from ¬c, return the target chunk, the leftover (may be empty), and whether we're done consuming the body.iGet the response body.jGet the response status code.k Get the response status message.l+Lookup a particular header from a response.mGet the response Ç.Ë0Max length of preview fragment of response body.  Response with body reader insideThe final resultI HTTP method' location of resourceBody of the request A hint how to interpret response!Collection of optional parametersResponseJ HTTP method' location of resourceBody of the request!Collection of optional parametersHow to consume responseResultK HTTP method' location of resourceBody of the request!Collection of optional parametersHow to perform requestResultM> to useComputation to runW Header name Header valueZUsernamePasswordAuth [UsernamePasswordAuth \UsernamePasswordAuth ]Consumer tokenConsumer secret OAuth tokenOAuth token secretAuth ^TokenAuth _TokenAuth b/Predicate that is given MIME type, it returns ¹0 when content should be decompressed on the fly.cNumber of microseconds to waitdMajor version numberMinor version numberÉHow many bytes to fetch Response with body reader insidePreview ®) and new response with body reader insideÊBody reader to stream fromHow many bytes to consume.Target chunk, the leftover, whether we're donelResponse interpretationHeader to lookupHeader value if foundn  !"#$%&'()*+,-./0123456789:;<=>?DEC@ABFHGIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnIJKLFGH>?@ABCDE=M;<9:78563412/0-.+,()*'NOPQRS%&#$!" TUVWXYZ[\]^_`abcdefg hijklm #¥ÌŠª  ÍÎÏÐÑÒÓ !"#$%&'Ô()*+,-./0123456789:;<=Õ>?@ABCDEFGHP5Q5U7Ö       !!""##$$%%&&'()*++,,--..//001122334556789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œ žŸ ¡›œ¢£€¥Š§›œš›œ©˜™ª«¬­«®­ž¯ž°›œ±²³Ž›œµ›œ¶ž·ž¹º»Œœ˜™Ÿ¿ÀÁžÂÝÄŝÆÇÈÉÊËÌÍΛÏÐÑÒӝžÔ›œ՛œÖ×ØÙ  '4Ú req-1.1.0-2Zfe0b26E2LJFmKFRbhwBrNetwork.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 parseUrlHttpsreqBodyMultipart=: 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.12.1-6rTPCQZ1uuO16Zdww9dM59Network.HTTP.Client.TypesbaseGHC.BaseStringWombRequestComponentRequest Data.MonoidEndoData.Semigroup<> getRequestModResponse BodyReaderIObytestring-0.10.8.2Data.ByteString.Internal ByteStringData.ByteString.Lazy.InternalNothingMonoid RequestBody%aeson-0.11.3.0-FHnwrWmVc6S6jWSldfiocjData.Aeson.Types.ClassToJSONManagerHttpExceptionContentJust1data-default-class-0.1.2.0-65ekPiG1XHJGG1Sy8NeI1LData.Default.Classdef$retry-0.7.6.2-6rWI3h4752oIlhKuVRnged Control.Retry RetryPolicyMTrue mtl-2.2.2-IqWgmFcHnX2E7PrBkSGNvnControl.Monad.Reader.Class MonadReadermempty globalManager GHC.IO.UnsafeunsafePerformIO GHC.IORefIORef,http-api-data-0.3.8.1-9OgSz2XcFv3722dztO9ycfWeb.Internal.HttpApiData ToHttpApiData#text-1.2.2.2-EakMpasry3jA6OIwSZhq9MData.Text.InternalTextparseUrlHelper%Network.HTTP.Client.MultipartFormDataPartwithQueryParams withRequestfinalizeRequestmappend CookieJarManagerSettings grabPreviewbrReadNbodyPreviewLength