1
0
mirror of https://github.com/actix/actix-website synced 2024-11-28 02:22:57 +01:00
actix-website/content/docs/http2.md
2022-03-07 13:40:36 +00:00

33 lines
1.4 KiB
Markdown

---
title: HTTP/2
menu: docs_protocols
weight: 250
---
Actix Web will prefer HTTP/2 connections if the client signals support for it via [TLS ALPN][tlsalpn].
# Negotiation
<!-- TODO: use rustls example -->
When either of the `rustls` or `openssl` features are enabled, `HttpServer` provides the [bind_rustls][bindrustls] method and [bind_openssl][bindopenssl] methods, respectively.
```toml
[dependencies]
actix-web = { version = "{{< actix-version "actix-web" >}}", features = ["openssl"] }
openssl = { version = "0.10", features = ["v110"] }
```
{{< include-example example="http2" file="main.rs" section="main" >}}
Upgrades to HTTP/2 described in [RFC §3.2][rfcsection32] are not supported. Starting HTTP/2 with prior knowledge is supported for both cleartext and TLS connections ([RFC §3.4][rfcsection34]) (when using the lower level `actix-http` service builders).
> Check out [examples/tls][examples] for a concrete example.
[rfcsection32]: https://http2.github.io/http2-spec/#rfc.section.3.2
[rfcsection34]: https://http2.github.io/http2-spec/#rfc.section.3.4
[bindrustls]: https://docs.rs/actix-web/4/actix_web/struct.HttpServer.html#method.bind_rustls
[bindopenssl]: https://docs.rs/actix-web/4/actix_web/struct.HttpServer.html#method.bind_openssl
[tlsalpn]: https://tools.ietf.org/html/rfc7301
[examples]: https://github.com/actix/examples/tree/master/https-tls/rustls