http-streams: An HTTP client using io-streams

[ bsd3, io-streams, library, web ] [ Propose Tags ]

An HTTP client, using the Snap Framework's 'io-streams' library to handle the streaming IO. The API is optimized for ease of use for the rather common case of code needing to query web services and deal with the result.

The library is exported in a single module; see Network.Http.Client for full documentation.


[Skip to Readme]

Modules

[Index] [Quick Jump]

  • Network
    • Http
      • Network.Http.Client
      • Network.Http.Connection
      • Network.Http.Inconvenience
      • Network.Http.ResponseParser

Flags

Automatic Flags
NameDescriptionDefault
network-uri

Get Network.URI from the network-uri package

Enabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.3.1.0, 0.4.0.0, 0.4.0.1, 0.5.0.0, 0.5.0.1, 0.5.0.2, 0.6.0.0, 0.6.0.1, 0.6.0.2, 0.6.1.0, 0.6.1.1, 0.7.0.1, 0.7.0.2, 0.7.1.1, 0.7.1.2, 0.7.2.0, 0.7.2.2, 0.7.2.3, 0.7.2.4, 0.7.2.5, 0.7.2.6, 0.8.3.1, 0.8.3.2, 0.8.3.3, 0.8.4.0, 0.8.5.2, 0.8.5.3, 0.8.5.5, 0.8.6.1, 0.8.7.1, 0.8.7.2, 0.8.8.1, 0.8.9.4, 0.8.9.6, 0.8.9.8, 0.8.9.9 (info)
Change log CHANGELOG.md
Dependencies aeson (<2.3), attoparsec, attoparsec-aeson (<2.3), base (>=4.5 && <5), base64-bytestring, blaze-builder (>=0.4), bytestring, case-insensitive, directory, filepath, HsOpenSSL (>=0.11.2), http-common (>=0.8.3.4), io-streams (>=1.3 && <1.6), mtl, network, network-uri, openssl-streams (>=1.1 && <1.4), text, transformers, unordered-containers [details]
License BSD-3-Clause
Copyright © 2012-2023 Athae Eredh Siniath and Others
Author Andrew Cowie <istathar@gmail.com>
Maintainer Andrew Cowie <istathar@gmail.com>
Category Web, IO-Streams
Home page https://github.com/aesiniath/http-streams/
Bug tracker https://github.com/aesiniath/http-streams/issues
Source repo head: git clone git://github.com/aesiniath/http-streams.git
Uploaded by AndrewCowie at 2023-10-20T05:39:49Z
Distributions Arch:0.8.9.9, Debian:0.8.7.2, Fedora:0.8.9.8, LTSHaskell:0.8.9.9, NixOS:0.8.9.9, Stackage:0.8.9.9
Reverse Dependencies 29 direct, 22 indirect [details]
Downloads 33532 total (144 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for http-streams-0.8.9.9

[back to package description]

An HTTP client

An HTTP client library for Haskell using the Snap Framework's io-streams library to handle the streaming IO.

A common case in writing RESTful web services is needing to make onward calls to further servers. This package is intended to make this easy to do. Though originally written for making calls from web apps written with Snap, you can use this from any library or framework.

Enjoy!

Example

The underlying API is very simple:

main :: IO ()
main = do
    c <- openConnection "www.example.com" 80
    
    let q = buildRequest1 $ do
                http GET "/"
                setAccept "text/html"
    
    sendRequest c q emptyBody
    
    receiveResponse c (\p i -> do
    	putStr $ show p

    	x <- Streams.read i
    	S.putStr $ fromMaybe "" x)
    
    closeConnection c

There are also convenience functions for the common case of making straight-forward GET and POST requests; for instance:

    get "http://www.example.com/" (\_ i -> Streams.connect i stdout)

will {ahem} stream the response body to stdout. Perhaps more interesting (though less streams-oriented), is simply getting the response as a ByteString using one of the pre-defined handlers:

    x' <- get "https://secure.example.com/" concatHandler

See the documentation in Network.Http.Client for further examples and details of usage of the API.