The http-streams package

[Tags:bsd3, library]

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]

Properties

Versions 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 (info)
Change log CHANGELOG.markdown
Dependencies aeson, attoparsec, base (==4.*), base64-bytestring, blaze-builder (>=0.4), bytestring, case-insensitive, directory, HsOpenSSL (>=0.10.3.5), http-common (>=0.8.2), io-streams (==1.3.*), mtl, network, network-uri, openssl-streams (>=1.1 && <1.4), text, transformers, unordered-containers [details]
License BSD3
Copyright © 2012-2015 Operational Dynamics Consulting, Pty Ltd and Others
Author Andrew Cowie <andrew@operationaldynamics.com>
Maintainer Andrew Cowie <andrew@operationaldynamics.com>
Stability experimental
Category Web, IO-Streams
Home page http://research.operationaldynamics.com/projects/http-streams/
Bug tracker https://github.com/afcowie/http-streams/issues
Source repository head: git clone git://github.com/afcowie/http-streams.git
Uploaded Fri Jun 12 05:14:15 UTC 2015 by AndrewCowie
Distributions Debian:0.8.3.3, LTSHaskell:0.8.3.3, NixOS:0.8.3.3
Downloads 7561 total (75 in the last 30 days)
Votes
1 []
Status Docs available [build log]
Last success reported on 2015-06-12 [all 1 reports]

Modules

[Index]

Flags

NameDescriptionDefaultType
network-uriGet Network.URI from the network-uri packageEnabledAutomatic

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

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for http-streams

Readme for http-streams-0.8.3.3

An HTTP client

An HTTP client library for Haskell using the Snap Framework's io-streams library to handle the streaming IO. <!-- replace with link to hackage when it is released -->

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