1
0
mirror of https://github.com/actix/actix-website synced 2024-12-18 18:03:12 +01:00
actix-website/examples/server/src/keep_alive_tp.rs

21 lines
508 B
Rust
Raw Normal View History

#![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