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 requests hanging #4261

Closed
RX14 opened this issue Apr 9, 2017 · 2 comments
Closed

HTTP requests hanging #4261

RX14 opened this issue Apr 9, 2017 · 2 comments
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib
Milestone

Comments

@RX14
Copy link
Contributor

RX14 commented Apr 9, 2017

require "json"
require "http"

struct Body
  JSON.mapping(
    content: String
  )
end

server = HTTP::Server.new(8080) do |context|
  context.request.body.try do |body|
    body = Body.from_json(body)
    puts body.content
  end
end

server.listen

Test using curl -v -d '{"content": "foo"}' http://localhost:8080/.

Expected result: foo printed to server console, HTTP request returns response.

Actual result: CURL hangs after sending data, foo not printed to server stdout. Manually quitting curl with ^C will print foo to the console and complete the HTTP request.

I think something weird is happening with IO::Sized, but I'm not entirely sure whether the blame lies there or in the JSON parsing.

crystal -v
Crystal 0.21.1 [3c6c75e] (2017-03-06) LLVM 3.5.0
@asterite asterite added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib labels Apr 9, 2017
@asterite
Copy link
Member

asterite commented Apr 9, 2017

Ugh, another issue because of IO#peek. I think we'll need to revert those changes, it's a mess and it's probably a bad design. I was the only one who though about how to deal with that, so it's better if we revert all of that and think it all over again. Sorry...

@asterite asterite added this to the Next milestone Apr 9, 2017
@asterite
Copy link
Member

asterite commented Apr 9, 2017

Or maybe it was just a small bug :-)

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