From f504c658620a50c474531c8d5725e747d672034a Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 5 Mar 2022 23:54:23 +0000 Subject: [PATCH] remove outdated info about force closing connections --- content/docs/server.md | 7 ++----- examples/server/src/keep_alive_tp.rs | 14 -------------- examples/server/src/main.rs | 1 - 3 files changed, 2 insertions(+), 20 deletions(-) delete mode 100644 examples/server/src/keep_alive_tp.rs diff --git a/content/docs/server.md b/content/docs/server.md index 7d0caaa..45048e6 100644 --- a/content/docs/server.md +++ b/content/docs/server.md @@ -91,14 +91,10 @@ Actix Web keeps connections open to wait for subsequent requests. {{< include-example example="server" file="keep_alive.rs" section="keep-alive" >}} -If the first option above is selected, then _keep alive_ state is calculated based on the response's _connection-type_. By default `HttpResponse::connection_type` is not defined. In that case -keep-alive is defined by the request's HTTP version. +If the first option above is selected, then keep-alive is enabled for HTTP/1.1 requests if the response does not explicitly disallow it by, for example, setting the [connection type][httpconnectiontype] to `Close` or `Upgrade`. Force closing a connection can be done with [the `force_close()` method on `HttpResponseBuilder`](https://docs.rs/actix-web/3/actix_web/dev/struct.HttpResponseBuilder.html#method.force_close) > Keep-alive is **off** for HTTP/1.0 and is **on** for HTTP/1.1 and HTTP/2.0. -_Connection type_ can be changed with `HttpResponseBuilder::connection_type()` method. - -{{< include-example example="server" file="keep_alive_tp.rs" section="example" >}} - ## Graceful shutdown `HttpServer` supports graceful shutdown. After receiving a stop signal, workers have a specific amount of time to finish serving requests. Any workers still alive after the timeout are force-dropped. By default the shutdown timeout is set to 30 seconds. You can change this parameter with the [`HttpServer::shutdown_timeout()`][shutdowntimeout] method. @@ -121,3 +117,4 @@ _Connection type_ can be changed with `HttpResponseBuilder::connection_type()` m [exampleopenssl]: https://github.com/actix/examples/tree/master/security/openssl [shutdowntimeout]: https://docs.rs/actix-web/3/actix_web/struct.HttpServer.html#method.shutdown_timeout [disablesignals]: https://docs.rs/actix-web/3/actix_web/struct.HttpServer.html#method.disable_signals +[httpconnectiontype]: https://docs.rs/actix-web/3/actix_web/http/enum.ConnectionType.html diff --git a/examples/server/src/keep_alive_tp.rs b/examples/server/src/keep_alive_tp.rs deleted file mode 100644 index 003b730..0000000 --- a/examples/server/src/keep_alive_tp.rs +++ /dev/null @@ -1,14 +0,0 @@ -// -use actix_web::{http, HttpRequest, HttpResponse}; - -async fn index(req: HttpRequest) -> HttpResponse { - HttpResponse::Ok() - .connection_type(http::ConnectionType::Close) // <- Close connection - .force_close() // <- Alternative method - .finish() -} -// - -// ConnectionType::Close -// ConnectionType::KeepAlive -// ConnectionType::Upgrade diff --git a/examples/server/src/main.rs b/examples/server/src/main.rs index b6d5c1c..77155d2 100644 --- a/examples/server/src/main.rs +++ b/examples/server/src/main.rs @@ -1,5 +1,4 @@ pub mod keep_alive; -// pub mod keep_alive_tp; pub mod signals; pub mod ssl; pub mod workers;