An HTTP/2 implementation in Rust.
The main goal of the project is to provide a low-level implementation of the HTTP/2 protocol and expose it in a way that higher-level libraries can make use of it. For example, it should be possible for a higher level libary to write a simple adapter that exposes the responses obtained over an HTTP/2 connection in the same manner as those obtained over HTTP/1.1.
The API should make it possible to use an HTTP/2 connection at any level -- everything from sending and managing individual HTTP/2 frames to only manipulating requests and responses -- depending on the needs of the end users of the library.
The core of the library should be decoupled from the particulars of the underlying IO -- it should be possible to use the same APIs regardless if the IO is evented or blocking. In the same time, the library provides convenience adapters that allow the usage of Rust's standard library socket IO as the transport layer out of the box.
Extensive test coverage is also a major goal. No code is committed without accompanying tests.
At this stage, performance was not considered as one of the primary goals.
As mentioned in the goals section, this library does not aim to provide a full high-level client or server implementation (no caching, no automatic redirect following, no strongly-typed headers, etc.).
However, in order to demonstrate how such components could be built or provide
a baseline for less demanding versions of the same, implementations of a limited
client and server are included in the crate (the modules
The simple client implementation allows users to issue a number of requests before blocking to read one of the responses. After a response is received, more requests can be sent over the same connection; however, requests cannot be queued while a response is being read.
In a way, this is similar to how HTTP/1.1 connections with keep-alive (and pipelining) work.
A clear-text (
extern crate solicit; use CleartextConnector; use SimpleClient; use str;
A TLS-protected (and negotiated)
https:// connection. The only difference is
in the type of the connector provided to the
tls feature of the crate.
extern crate solicit; use TlsConnector; use SimpleClient; use str;
For how it leverages the
solicit::http API for its implementation, check out the
The async client leverages more features specific to HTTP/2, as compared to HTTP/1.1.
It allows multiple clients to issue requests to the same underlying
connection concurrently. The responses are returned to the clients in the form
Future, allowing them to block on waiting for the response only once
they don't have anything else to do (which could be immediately after issuing
This client spawns one background thread per HTTP/2 connection, which exits gracefully once there are no more clients connected to it (and thus no more potential requests can be issued) or the HTTP/2 connection returns an error.
This client implementation is also just an example of what can be achieved
solicit::htp API -- see:
extern crate solicit; use Client; use CleartextConnector; use thread; use str;
The simple server implementation works similarly to the
server implementation is fully single-threaded: no responses can be written
while reading a request (and vice-versa). It does show how the API can be used
to implement an HTTP/2 server, though.
Provided by the
A server that echoes the body of each request that it receives.
extern crate solicit; use str; use ; use thread; use Response; use SimpleServer;
The project is published under the terms of the MIT License.