Fix timeouts for HTTP/1.1 non-chunked requests (missing Connection: close)

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
Azat Khuzhin 2024-01-19 14:42:52 +03:00
parent 38ad4ef493
commit d940afd6cd

View File

@ -19,6 +19,13 @@ void WriteBufferFromHTTPServerResponse::startSendHeaders()
if (response.getChunkedTransferEncoding())
setChunked();
else if (response.getContentLength() == Poco::Net::HTTPMessage::UNKNOWN_CONTENT_LENGTH)
{
/// In case there is no Content-Length we cannot use keep-alive,
/// since there is no way to know when the server send all the
/// data, so "Connection: close" should be sent.
response.setKeepAlive(false);
}
if (add_cors_header)
response.set("Access-Control-Allow-Origin", "*");