2023-03-03 16:07:26 +01:00
|
|
|
#![allow(dead_code)]
|
|
|
|
|
2022-07-16 11:59:20 +02:00
|
|
|
// <example>
|
|
|
|
use actix_web::{http, HttpRequest, HttpResponse};
|
|
|
|
|
2023-03-03 16:07:26 +01:00
|
|
|
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
|
2022-07-16 11:59:20 +02:00
|
|
|
}
|
|
|
|
// </example>
|
|
|
|
|
|
|
|
// ConnectionType::Close
|
|
|
|
// ConnectionType::KeepAlive
|
|
|
|
// ConnectionType::Upgrade
|