http-streams: An HTTP client using io-streams

[ bsd3, io-streams, library, web ] [ Propose Tags ] [ Report a vulnerability ]
This version is deprecated.

Overview

An HTTP client, using the Snap Framework's 'io-streams' library to hande 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]

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

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

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.markdown
Dependencies aeson (<2.2), attoparsec, base (>=4 && <5), base64-bytestring, blaze-builder (>=0.4), bytestring, case-insensitive, directory, HsOpenSSL (>=0.10.3.5), http-common (>=0.8.2), io-streams (>=1.3 && <1.4), mtl, network, network-uri, openssl-streams (>=1.1 && <1.4), text, transformers, unordered-containers [details]
Tested with ghc ==7.8
License BSD-3-Clause
Copyright © 2012-2015 Operational Dynamics Consulting, Pty Ltd and Others
Author Andrew Cowie <andrew@operationaldynamics.com>
Maintainer Andrew Cowie <andrew@operationaldynamics.com>
Revised Revision 1 made by AndreasAbel at 2023-10-16T23:23:39Z
Category Web, IO-Streams
Home page http://research.operationaldynamics.com/projects/http-streams/
Bug tracker https://github.com/afcowie/http-streams/issues
Source repo head: git clone git://github.com/afcowie/http-streams.git
Uploaded by AndrewCowie at 2015-04-28T00:43:33Z
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 30 direct, 22 indirect [details]
Downloads 34430 total (240 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2015-04-28 [all 1 reports]

Readme for http-streams-0.8.3.1

[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 wep 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. There's also a blog post introducing the library with a discussion of the design and usage.

Change Log

Now included in separate file CHANGELOG.

AfC