2018-05-22 23:15:08 +02:00
|
|
|
---
|
2020-09-12 17:21:54 +02:00
|
|
|
title: HTTP/2
|
|
|
|
menu: docs_protocols
|
2018-05-22 23:15:08 +02:00
|
|
|
weight: 250
|
|
|
|
---
|
|
|
|
|
2020-09-12 17:21:54 +02:00
|
|
|
`actix-web` automatically upgrades connections to *HTTP/2* if possible.
|
2018-05-22 23:15:08 +02:00
|
|
|
|
|
|
|
# Negotiation
|
|
|
|
|
2020-09-12 17:21:54 +02:00
|
|
|
*HTTP/2* protocol over TLS without prior knowledge requires [TLS ALPN][tlsalpn].
|
2018-05-22 23:15:08 +02:00
|
|
|
|
2020-09-12 17:21:54 +02:00
|
|
|
<!-- TODO: use rustls example -->
|
2018-05-22 23:15:08 +02:00
|
|
|
> Currently, only `rust-openssl` has support.
|
|
|
|
|
|
|
|
`alpn` negotiation requires enabling the feature. When enabled, `HttpServer` provides the
|
2019-12-28 17:37:19 +01:00
|
|
|
[bind_openssl][bindopenssl] method.
|
2018-05-22 23:15:08 +02:00
|
|
|
|
|
|
|
```toml
|
|
|
|
[dependencies]
|
2019-12-28 17:37:19 +01:00
|
|
|
actix-web = { version = "{{< actix-version "actix-web" >}}", features = ["openssl"] }
|
2018-05-22 23:15:08 +02:00
|
|
|
openssl = { version = "0.10", features = ["v110"] }
|
|
|
|
```
|
2019-06-18 23:17:43 +02:00
|
|
|
{{< include-example example="http2" file="main.rs" section="main" >}}
|
2018-05-22 23:15:08 +02:00
|
|
|
|
2019-06-25 05:36:32 +02:00
|
|
|
Upgrades to *HTTP/2.0* schema described in [rfc section 3.2][rfcsection32] is not
|
|
|
|
supported. Starting *HTTP/2* with prior knowledge is supported for both clear text
|
|
|
|
connection and tls connection. [rfc section 3.4][rfcsection34].
|
2018-05-22 23:15:08 +02:00
|
|
|
|
2019-06-25 05:36:32 +02:00
|
|
|
> 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
|
2020-09-12 17:21:54 +02:00
|
|
|
[bindopenssl]: https://docs.rs/actix-web/3/actix_web/struct.HttpServer.html#method.bind_openssl
|
2019-06-25 05:36:32 +02:00
|
|
|
[tlsalpn]: https://tools.ietf.org/html/rfc7301
|
2021-02-26 19:48:27 +01:00
|
|
|
[examples]: https://github.com/actix/examples/tree/master/security/rustls
|