Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lukehoersten/http-client-streams
http-client + openssl + io-streams
https://github.com/lukehoersten/http-client-streams
Last synced: about 2 months ago
JSON representation
http-client + openssl + io-streams
- Host: GitHub
- URL: https://github.com/lukehoersten/http-client-streams
- Owner: lukehoersten
- License: bsd-2-clause
- Created: 2014-12-21T14:56:13.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-04-02T20:19:38.000Z (almost 10 years ago)
- Last Synced: 2023-04-10T23:24:02.783Z (over 1 year ago)
- Language: Haskell
- Size: 121 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
http-client-streams [![Hackage](https://img.shields.io/hackage/v/http-client-streams.svg?style=flat)](https://hackage.haskell.org/package/http-client-streams) [![Build Status](https://travis-ci.org/dmjio/http-client-streams.svg)](https://travis-ci.org/dmjio/http-client-streams)
===================## Usage
```haskell
{-# LANGUAGE OverloadedStrings #-}
module Main whereimport qualified System.IO.Streams as Streams
import System.IO.Streams.HTTP ( opensslManagerSettings
, parseUrl
, withManager
, withHTTP
, responseBody
, withOpenSSL
, context
)------------------------------------------------------------------------------
-- | OpenSSL test (GET)
main :: IO ()
main = withOpenSSL $ do
req <- parseUrl "https://google.com"
withManager (opensslManagerSettings context) $ \mgr ->
withHTTP req mgr $ \resp ->
Streams.supplyTo Streams.stdout (responseBody resp)------------------------------------------------------------------------------
-- | OpenSSL test (POST)
post :: IO ()
post = withOpenSSL $ do
let settings =
req <- parseUrl "https://google.com"
let request = req { method = "POST"
, requestBody = stream $ Streams.fromLazyByteString "body"
}
withManager (opensslManagerSettings context) $ \mgr ->
withHTTP request mgr $ \resp ->
Streams.supplyTo Streams.stdout (responseBody resp)
```