Hoogle Search
Within LTS Haskell 24.67 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
-
HTTP client library HTTP client library.
-
The documentation below is structured in such a way that the most important information is presented first: you learn how to do HTTP requests, how to embed them in the monad you have, and then it gives you details about less-common things you may want to know about. The documentation is written with sufficient coverage of details and examples, and it's designed to be a complete tutorial on its own.
About the library
Req is an HTTP client library that attempts to be easy-to-use, type-safe, and expandable. “Easy-to-use” means that the library is designed to be beginner-friendly so it's simple to add to your monad stack, intuitive to work with, well-documented, and does not get in your way. Doing HTTP requests is a common task and a Haskell library for this should be approachable and clear to beginners, thus certain compromises were made. For example, one cannot currently modify ManagerSettings of the default manager because the library always uses the same implicit global manager for simplicity and maximal connection sharing. There is a way to use your own manager with different settings, but it requires more typing. “Type-safe” means that the library tries to eliminate certain classes of errors. For example, we have correct-by-construction URLs; it is guaranteed that the user does not send the request body when using methods like GET or OPTIONS, and the amount of implicit assumptions is minimized by making the user specify their intentions in an explicit form. For example, it's not possible to avoid specifying the body or the method of a request. Authentication methods that assume HTTPS force the user to use HTTPS at the type level. “Expandable” refers to the ability to create new components without having to resort to hacking. For example, it's possible to define your own HTTP methods, create new ways to construct the body of a request, create new authorization options, perform a request in a different way, and create your own methods to parse a response.Using with other libraries
- You won't need the low-level interface of http-client most of the time, but when you do, it's better to do a qualified import, because http-client has naming conflicts with req.
- For streaming of large request bodies see the companion package req-conduit: https://hackage.haskell.org/package/req-conduit.
Lightweight, no risk solution
The library uses the following mature packages under the hood to guarantee you the best experience:- https://hackage.haskell.org/package/http-client—low level HTTP client used everywhere in Haskell.
- https://hackage.haskell.org/package/http-client-tls—TLS (HTTPS) support for http-client.
-
req Network.HTTP.Req This data type represents empty body of an HTTP request. This is the data type to use with HttpMethods that cannot have a body, as it's the only type for which ProvidesBody returns NoBody. Using of this body option does not set the Content-Type header.
-
req Network.HTTP.Req No documentation available.
-
req Network.HTTP.Req A monad that allows us to run req in any IO-enabled monad without having to define new instances.
-
req Network.HTTP.Req HTTP request body represented by a strict ByteString. Using of this body option does not set the Content-Type header.
ReqBodyBs :: ByteString -> ReqBodyBsreq Network.HTTP.Req No documentation available.
-
req Network.HTTP.Req This body option streams request body from a file. It is expected that the file size does not change during streaming. Using of this body option does not set the Content-Type header.
ReqBodyFile :: FilePath -> ReqBodyFilereq Network.HTTP.Req No documentation available.
-
req Network.HTTP.Req This body option allows us to use a JSON object as the request body—probably the most popular format right now. Just wrap a data type that is an instance of ToJSON 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.