|
Packit |
15527a |
http-client
|
|
Packit |
15527a |
===========
|
|
Packit |
15527a |
|
|
Packit |
15527a |
Full tutorial docs are available at:
|
|
Packit |
15527a |
https://haskell-lang.org/library/http-client
|
|
Packit |
15527a |
|
|
Packit |
15527a |
An HTTP client engine, intended as a base layer for more user-friendly packages.
|
|
Packit |
15527a |
|
|
Packit |
15527a |
This codebase has been refactored from [http-conduit](http://www.stackage.org/package/http-conduit).
|
|
Packit |
15527a |
|
|
Packit |
15527a |
Note that, if you want to make HTTPS secure connections, you should use
|
|
Packit |
15527a |
[http-client-tls](https://www.stackage.org/package/http-client-tls) in addition
|
|
Packit |
15527a |
to this library.
|
|
Packit |
15527a |
|
|
Packit |
15527a |
Below is a series of cookbook recipes. A number of recipes exist elsewhere,
|
|
Packit |
15527a |
including `Network.HTTP.Client` and `Network.HTTP.Conduit`. The goal is to
|
|
Packit |
15527a |
expand this list over time.
|
|
Packit |
15527a |
|
|
Packit |
15527a |
## Proxy environment variable
|
|
Packit |
15527a |
|
|
Packit |
15527a |
Use the following approach to get proxy settings from the `http_proxy` and
|
|
Packit |
15527a |
`https_proxy` environment variables.
|
|
Packit |
15527a |
|
|
Packit |
15527a |
```haskell
|
|
Packit |
15527a |
{-# LANGUAGE OverloadedStrings #-}
|
|
Packit |
15527a |
import Network.HTTP.Client
|
|
Packit |
15527a |
|
|
Packit |
15527a |
main :: IO ()
|
|
Packit |
15527a |
main = do
|
|
Packit |
15527a |
let settings = managerSetProxy
|
|
Packit |
15527a |
(proxyEnvironment Nothing)
|
|
Packit |
15527a |
defaultManagerSettings
|
|
Packit |
15527a |
man <- newManager settings
|
|
Packit |
15527a |
let req = "http://httpbin.org"
|
|
Packit |
15527a |
-- Note that the following settings will be completely ignored.
|
|
Packit |
15527a |
{ proxy = Just $ Proxy "localhost" 1234
|
|
Packit |
15527a |
}
|
|
Packit |
15527a |
httpLbs req man >>= print
|
|
Packit |
15527a |
```
|