We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When content length is less than 512 bytes then output is wrongly send to client.
test:
public void routing(HttpRouting.Builder routing) { int LENGTH = 511; routing.get("/test_stream", (req, res) -> { String content ="a".repeat(LENGTH); InputStream in = new ByteArrayInputStream(content.getBytes()); in.transferTo(res.outputStream()); }); routing.get("/test_string", (req, res) -> { String content ="a".repeat(LENGTH); res.send(content.getBytes()); }); }
output:
send not using OutputStream
OutputStream
curl -k -i -X GET https://localhost:8080/test_string HTTP/1.1 200 OK Date: Wed, 19 Apr 2023 13:31:16 +0200 Connection: keep-alive Content-Length: 511 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
send using OutputStream
curl -k -i -X GET https://localhost:8080/test_stream HTTP/1.1 200 OK Date: Wed, 19 Apr 2023 13:31:13 +0200 Connection: keep-alive Content-Length: 0
When we increase LENGTH to 512 everything works correct.
The text was updated successfully, but these errors were encountered:
not sure if this problem is related to #6501
Sorry, something went wrong.
@wojtask9 Could you try explicitly flushing the output stream? There's new buffering to avoid some problems. See #6509.
@spericas
OutputStream os = res.outputStream(); in.transferTo(os); os.flush();
With explicit flush everything works :)
flush
@wojtask9 I will create a PR to do auto-flushing at the end for convenience.
spericas
No branches or pull requests
Environment Details
Problem Description
When content length is less than 512 bytes then output is wrongly send to client.
Steps to reproduce
test:
output:
send not using
OutputStream
send using
OutputStream
When we increase LENGTH to 512 everything works correct.
The text was updated successfully, but these errors were encountered: