mirror of
https://github.com/actix/actix-website
synced 2024-12-18 18:03:12 +01:00
04f6f0bd02
* fixed keep-alive on response example * fixed dead code and unused variable errors
21 lines
508 B
Rust
21 lines
508 B
Rust
#![allow(dead_code)]
|
|
|
|
// <example>
|
|
use actix_web::{http, HttpRequest, HttpResponse};
|
|
|
|
async fn index(_req: HttpRequest) -> HttpResponse {
|
|
let mut resp = HttpResponse::Ok()
|
|
.force_close() // <- Close connection on HttpResponseBuilder
|
|
.finish();
|
|
|
|
// Alternatively close connection on the HttpResponse struct
|
|
resp.head_mut().set_connection_type(http::ConnectionType::Close);
|
|
|
|
resp
|
|
}
|
|
// </example>
|
|
|
|
// ConnectionType::Close
|
|
// ConnectionType::KeepAlive
|
|
// ConnectionType::Upgrade
|