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::Server bug on keep alive request #2908

Closed
asterite opened this issue Jun 24, 2016 · 2 comments
Closed

HTTP::Server bug on keep alive request #2908

asterite opened this issue Jun 24, 2016 · 2 comments
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib
Milestone

Comments

@asterite
Copy link
Member

The problem is in these lines:

crystal/src/http/server.cr

Lines 171 to 176 in fd9bd6f

begin
request = HTTP::Request.from_io(io)
rescue e
STDERR.puts "Bug: Unhandled exception while parsing request"
e.inspect_with_backtrace(STDERR)
end

On the rescue branch request must be set to nil, otherwise on an exception it will keep the value of the previous iteration, which is wrong.

The fix is easy, but I'd like to add a spec to prevent regressions... but I don't know how to easily do it.

Originally discovered by @mverzilli and @waj

@asterite asterite added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib labels Jun 24, 2016
@asterite asterite added this to the 0.18.5 milestone Jun 24, 2016
@jhass
Copy link
Member

jhass commented Jun 24, 2016

We probably should allow injecting the server socket instead of forcing it to be build by HTTP::Server itself. Then the tests can just inject a fake backed by MemoryIO or similar. That would also partly address #2735

@asterite
Copy link
Member Author

There's another issue: when the IO is closed the server tries to response with an error, many times, but the IO is closed. This ends up bubbling an exception to main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib
Projects
None yet
Development

No branches or pull requests

2 participants