Here is an example GET request that streams the response body to
standard output:
import Pipes
import Pipes.HTTP
import qualified Pipes.ByteString as PB -- from `pipes-bytestring`
main = do
req <- parseUrlThrow "https://www.example.com"
manager <- withManager tlsManagerSettings
withHTTP req manager $ \resp ->
runEffect $ responseBody resp >-> PB.stdout
Here is an example POST request that also streams the request body
from standard input:
{-# LANGUAGE OverloadedStrings #-}
import Pipes
import Pipes.HTTP
import qualified Pipes.ByteString as PB
main = do
req <- parseUrlThrow "https://www.example.com"
let req' = req
{ method = "POST"
, requestBody = stream PB.stdin
}
manager <- newManager tlsManagerSettings
withHTTP req' manager $ \resp ->
runEffect $ responseBody resp >-> PB.stdout
For non-streaming request bodies, study the
RequestBody type,
which also accepts strict / lazy bytestrings or builders.