servant-http2-client: Generate HTTP2 clients from Servant API descriptions.

[ bsd3, library, web ] [ Propose Tags ]


[Index] [Quick Jump]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS],,
Change log
Dependencies base (>=4.7 && <5), binary (>= && <0.9), bytestring (>= && <0.11), case-insensitive (>= && <1.3), containers (>= && <0.6), exceptions (>=0.10.0 && <0.11), http-media (>= && <0.8), http-types (>=0.12.2 && <0.13), http2 (>=1.6.3 && <1.7), http2-client (>= && <0.9), mtl (>=2.2.2 && <2.3), servant-client-core (>=0.14.1 && <0.15), text (>= && <1.3), transformers (>= && <0.6) [details]
License BSD-3-Clause
Copyright 2018 Lucas DiCioccio
Author Lucas DiCioccio
Category Web
Home page
Bug tracker
Source repo head: git clone
Uploaded by LucasDiCioccio at 2018-10-27T18:09:58Z
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 1538 total (11 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-10-27 [all 1 reports]

Readme for servant-http2-client-

[back to package description]


This package provides a way to generate HTTP2 client code from Servant API descriptions.

Please consider this package somewhat unstable. The author would appreciate feedbacks and benchmarks in real-world deployments.


The usage is pretty similar to servant-client but uses an HTTP2Client rather than a Manager. See also the section below to highlight differences between servant-client and servant-http2-client.

HTTP2 uses a flow-control mechanism, which http2-client exposes but servant-http2-client hides: as a client you have nothing to do and DATA-credit is immediately sent to the server. This mechanism is easy for the user but effectively disables flow control at the application level. Further, this easy-to-use mechanism may have some slight overhead for sending many small control frames. Future version of the library will expose more control points (at an increased cost).

You can find a full example at ./test/Spec.hs .

Differences with servant-client

The client leverages http2-client and hence behave slightly differently from servant-client, which uses http-client. Most notably, HTTP/2 uses a single TCP connection for performing concurrent requests, whereas HTTP/1.x at best pipelines request sequentially over a same connection.

The servant-client library uses a connection Manager to create new TCP connections or try re-using existing connections. This servant-http2-client makes no use of such a Manager. This difference is mostly important for load-balancing and unstable network environments. When targeting a load-balanced server, a servant-http2-client will always hit the same TCP-endpoint whereas a servant-client may hit different TCP-endpoint for each request. Also, after handling a connection error, a servant-client will open a new TCP connection without any decision from the programmer. Conversely, a broken servant-http2-client will be of no practical use and the programmer must create a new H2ClientEnv. A Manager abstraction may be added to http2-client later.

The servant-client package offers Cookies handling, whereas servant-http2-client has no such feature. Please consider opening a pull-request for adding the support.

Finally, it's always good to remember that HTTP2 allows concurrent queries, that is, many API calls may fail when a single TCP connection dies out.