Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP client hangs if zero-length file sent #54

Open
mk90 opened this issue Feb 17, 2022 · 2 comments
Open

HTTP client hangs if zero-length file sent #54

mk90 opened this issue Feb 17, 2022 · 2 comments

Comments

@mk90
Copy link

mk90 commented Feb 17, 2022

print $self "Content-Length: $size$CRLF" if $size;

Using send_file_response with empty file suppress "Content-Length" header line, because "if $size" contstruction treated as false.

Then library succsessfully complete operation with RC_OK code, but HTTP client waits data from server, and timeout occured as a result.

Removing "if $size" resolve this problem.

@oalders
Copy link
Member

oalders commented Feb 17, 2022

That's not great! @vanHoesel, do you know what the correct behaviour here is? Just send a Content-Length of 0? It's not clear to me what the use case is for sending an empty file.

@ppisar
Copy link
Contributor

ppisar commented Jul 8, 2022

It depends on HTTP version and transfer encoding. But in general if the size is known to be 0, it should be indicated with "0". See https://www.ietf.org/rfc/rfc7230.html#section-3.3.2 for HTTP/1.1 and https://www.ietf.org/rfc/rfc1945.html#section-10.4 for HTTP/1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants