elnormous / elnormous/HTTPRequest

A 204 response results in timeouts if connection is kept-alive...

Open
#70 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
970
Forks
200
PR merge metrics
No merged PRs in 30d

Description

Hi,

I've noticed that a response with status 204 to, e.g., a POST request always results in a timeout if the connection is kept alive. RFC9110 specifies in 8.6 (https://www.rfc-editor.org/rfc/rfc9110.html#name-content-length) that `A server MUST NOT send a Content-Length header field in any response with a status code of 1xx (Informational) or 204 (No Content).`

It seems that the library is still trying to parse the body of a 204 response. But since the header of such a response does not contain a `Content-Length` field, `contentLengthReceived` stays `false` and the library tries to receive more data via the socket. If the server closes the connection, we won't receive any more data from the socket and the function returns the response. But if the connection is kept-alive, the `socket.recv()`-call will timeout as the server is not sending any more data but the socket is still open.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.