1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-21 23:00:50 +03:00

Enable HTTP keepalive correctly

This commit is contained in:
Quentin Gliech
2023-09-14 16:57:30 +02:00
parent 54071c4969
commit 386de570c7
4 changed files with 16 additions and 4 deletions

View File

@@ -176,7 +176,7 @@ where
} else {
hyper::server::conn::Http::new()
.http1_only(true)
.http1_keep_alive(false)
.http1_keep_alive(true)
.serve_connection(stream, service)
.with_upgrades()
.await?;

View File

@@ -152,10 +152,20 @@ impl UnixOrTcpListener {
match self {
Self::Unix(listener) => {
let (stream, remote_addr) = listener.accept().await?;
let socket = socket2::SockRef::from(&stream);
socket.set_keepalive(true)?;
socket.set_nodelay(true)?;
Ok((remote_addr.into(), UnixOrTcpConnection::Unix { stream }))
}
Self::Tcp(listener) => {
let (stream, remote_addr) = listener.accept().await?;
let socket = socket2::SockRef::from(&stream);
socket.set_keepalive(true)?;
socket.set_nodelay(true)?;
Ok((remote_addr.into(), UnixOrTcpConnection::Tcp { stream }))
}
}