Carl Lerche c4fc2928fe API cleanup (#155)
* Change send_reset to take &mut self.

While calling this function is the last thing that should be done with
the instance, the intent of the h2 library is not to be used directly by
users, but to be used as an implementation detail by other libraries.

Requiring `self` on `send_reset` is pretty annoying when calling the
function from inside a `Future` implementation. Also, all the other fns
on the type take `&mut self`.

* Remove the P: Peer generic from internals

* Split out `Respond` from `server::Stream`

This new type is used to send HTTP responses to the client as well as
reserve streams for push promises.

* Remove unused `Send` helper.

This could be brought back later when the API becomes stable.

* Unite `client` and `server` types

* Remove `B` generic from internal proto structs

This is a first step in removing the `B` generic from public API types
that do not strictly require it.

Currently, all public API types must be generic over `B` even if they do
not actually interact with the send data frame type. The first step in
removing this is to remove `B` as a generic on all internal types.

* Remove `Buffer<B>` from inner stream state

This is the next step in removing the `B` generic from all public API
types. The send buffer is the only type that requires `B`. It has now
been extracted from the rest of the stream state.

The strategy used in this PR requires an additional `Arc` and `Mutex`,
but this is not a fundamental requirement. The additional overhead can
be avoided with a little bit of unsafe code. However, this optimization
should not be made until it is proven that it is required.

* Remove `B` generic from `Body` + `ReleaseCapacity`

This commit actually removes the generic from these two public API
types. Also note, that removing the generic requires that `B: 'static`.
This is because there is no more generic on `Body` and `ReleaseCapacity`
and the compiler must be able to ensure that `B` outlives all `Body` and
`ReleaseCapacity` handles.

In practice, in an async world, passing a non 'static `B` is never going
to happen.

* Remove generic from `ResponseFuture`

This change also makes generic free types `Send`. The original strategy
of using a trait object meant that those handles could not be `Send`.
The solution was to avoid using the send buffer when canceling a stream.
This is done by transitioning the stream state to `Canceled`, a new
`Cause` variant.

* Simplify Send::send_reset

Now that implicit cancelation goes through a separate path, the
send_reset function can be simplified.

* Export types common to client & server at root

* Rename Stream -> SendStream, Body -> RecvStream

* Implement send_reset on server::Respond
2017-10-19 20:02:08 -07:00
2017-10-19 20:02:08 -07:00
2017-05-31 14:44:58 -07:00
2017-10-19 20:02:08 -07:00
2017-10-19 20:02:08 -07:00
2017-03-09 20:02:47 -08:00
2017-10-18 11:00:56 -07:00
2017-10-07 12:34:46 -07:00
2017-08-16 22:23:45 -07:00
2017-08-16 22:23:45 -07:00
2017-10-09 11:21:05 -07:00

H2

A Tokio aware, HTTP/2.0 client & server implementation for Rust.

Build Status Codecov

This library is not production ready. Do not try to use it in a production environment or you will regret it! This crate is still under active development and there has not yet been any focus on documentation (because you shouldn't be using it yet!).

More information about this crate can be found in the crate documentation

Features

  • Client and server HTTP/2.0 implementation.
  • Implements the full HTTP/2.0 specification.
  • Passes h2spec.
  • Focus on performance and correctness.
  • Built on Tokio.

Non goals

This crate is intended to only be an implementation of the HTTP/2.0 specification. It does not handle:

  • Managing TCP connections
  • HTTP 1.0 upgrade
  • TLS
  • Any feature not described by the HTTP/2.0 specification.

The intent is that this crate will eventually be used by hyper, which will provide all of these features.

Usage

To use h2, first add this to your Cargo.toml:

[dependencies]
h2 = { git = 'https://github.com/carllerche/h2' } # soon to be on crates.io!

Next, add this to your crate:

extern crate h2;

use h2::server::Server;

fn main() {
    // ...
}

License

h2 is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See LICENSE-APACHE, and LICENSE-MIT for details.

Description
No description provided
Readme 4.5 MiB
Languages
Rust 99.2%
Python 0.7%