mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-25 06:39:22 +02:00
update guide
This commit is contained in:
@ -85,3 +85,5 @@ fn main() {
|
||||
```
|
||||
|
||||
## User sessions
|
||||
|
||||
[WIP]
|
||||
|
@ -1,10 +1,10 @@
|
||||
# HTTP/2
|
||||
# HTTP/2.0
|
||||
|
||||
Actix web automatically upgrades connection to *HTTP/2* if possible.
|
||||
Actix web automatically upgrades connection to *HTTP/2.0* if possible.
|
||||
|
||||
## Negotiation
|
||||
|
||||
*HTTP/2* protocol over tls without prior knowlage requires
|
||||
*HTTP/2.0* protocol over tls without prior knowlage requires
|
||||
[tls alpn](https://tools.ietf.org/html/rfc7301). At the moment only
|
||||
`rust-openssl` has support. Turn on `alpn` feature to enable `alpn` negotiation.
|
||||
With enable `alpn` feature `HttpServer` provides
|
||||
@ -32,7 +32,7 @@ fn main() {
|
||||
}
|
||||
```
|
||||
|
||||
Upgrade to *HTTP/2* schema described in
|
||||
Upgrade to *HTTP/2.0* schema described in
|
||||
[rfc section 3.2](https://http2.github.io/http2-spec/#rfc.section.3.2) is not supported.
|
||||
Starting *HTTP/2* with prior knowledge is supported for both clear text connection
|
||||
and tls connection. [rfc section 3.4](https://http2.github.io/http2-spec/#rfc.section.3.4)
|
||||
|
@ -49,7 +49,7 @@ request handler with the application's `resource` on a particular *HTTP method*
|
||||
# }
|
||||
# fn main() {
|
||||
let app = Application::new()
|
||||
.resource("/", |r| r.method(Method::GET).f(index))
|
||||
.resource("/", |r| r.f(index))
|
||||
.finish();
|
||||
# }
|
||||
```
|
||||
|
@ -1,5 +1,6 @@
|
||||
# Server
|
||||
|
||||
|
||||
## Multi-threading
|
||||
|
||||
Http server automatically starts number of http workers, by default
|
||||
@ -52,7 +53,7 @@ fn main() {
|
||||
}
|
||||
```
|
||||
|
||||
Note on *HTTP/2* protocol over tls without prior knowlage, it requires
|
||||
Note on *HTTP/2.0* protocol over tls without prior knowlage, it requires
|
||||
[tls alpn](https://tools.ietf.org/html/rfc7301). At the moment only
|
||||
`openssl` has `alpn ` support.
|
||||
|
||||
@ -99,6 +100,7 @@ use actix_web::*;
|
||||
fn index(req: HttpRequest) -> HttpResponse {
|
||||
HTTPOk.build()
|
||||
.connection_type(headers::ConnectionType::Close) // <- Close connection
|
||||
.force_close() // <- Alternative method
|
||||
.finish().unwrap()
|
||||
}
|
||||
# fn main() {}
|
||||
|
@ -82,3 +82,45 @@ fn main() {
|
||||
.finish();
|
||||
}
|
||||
```
|
||||
|
||||
## Chunked transfer encoding
|
||||
|
||||
Actix automatically decode *chunked* encoding. `HttpRequest::payload()` already contains
|
||||
decoded bytes stream. If request payload compressed with one of supported
|
||||
compression codecs (br, gzip, deflate) bytes stream get decompressed.
|
||||
|
||||
Chunked encoding on response could be enabled with `HttpResponseBuilder::chunked()` method.
|
||||
But this takes effect only for `Body::Streaming(BodyStream)` or `Body::StreamingContext` bodies.
|
||||
Also if response payload compression is enabled and streaming body is used, chunked encoding
|
||||
get enabled automatically.
|
||||
|
||||
Enabling chunked encoding for *HTTP/2.0* responses is forbidden.
|
||||
|
||||
```rust
|
||||
# extern crate actix_web;
|
||||
use actix_web::*;
|
||||
use actix_web::headers::ContentEncoding;
|
||||
|
||||
fn index(req: HttpRequest) -> HttpResponse {
|
||||
HttpResponse::Ok()
|
||||
.chunked()
|
||||
.body(Body::Streaming(Payload::empty().stream())).unwrap()
|
||||
}
|
||||
# fn main() {}
|
||||
```
|
||||
|
||||
## Cookies
|
||||
|
||||
[WIP]
|
||||
|
||||
## Multipart body
|
||||
|
||||
[WIP]
|
||||
|
||||
## Urlencoded body
|
||||
|
||||
[WIP]
|
||||
|
||||
## Streaming request
|
||||
|
||||
[WIP]
|
||||
|
@ -1 +1,4 @@
|
||||
# WebSockets
|
||||
|
||||
[WIP]
|
||||
|
||||
|
Reference in New Issue
Block a user