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

Parsing POST response getting end of file reached error #44

Closed
sumits opened this issue Oct 7, 2013 · 5 comments
Closed

Parsing POST response getting end of file reached error #44

sumits opened this issue Oct 7, 2013 · 5 comments

Comments

@sumits
Copy link

sumits commented Oct 7, 2013

Using the awesome http gem for parsing response from a POST request. Response is a simple JSON, ~350 bytes. Response doesn't include the Content-Length header, which is not mandatory for normal HTTP communication. Digging more in the code, problem seems to be in the body/chunk parsing code in https://github.com/tarcieri/http/blob/master/lib/http/client.rb. Here's what I am seeing

  • Client requests a POST
  • Client gets and formats the response (I am able to see the 'chunk' in response)
  • Client creates a HTTP:Response instance
  • JSON MimeType is wired properly and works
  • When parsing the body, block in https://github.com/tarcieri/http/blob/master/lib/http/client.rb#L84 is hit once
  • Whole chunk is read once and since @body_remaining is nil, whole block above is executed again, which tries to read the socket again - which results into a EOF reached error

I saw a couple of open issues related to the same block of code, so the logic might have to be revisited or broken down even more.

@tarcieri
Copy link
Member

tarcieri commented Oct 7, 2013

@sumits long-term fix is #39

@sumits
Copy link
Author

sumits commented Oct 7, 2013

Thanks Tony, makes sense - should have dug around the project more.

@tarcieri
Copy link
Member

tarcieri commented Oct 7, 2013

@sumits getting the existing code fixed would be great too! But it's due for a rewrite...

@sferik
Copy link
Contributor

sferik commented Jan 23, 2014

Can this be closed now that #39 is merged?

@tarcieri
Copy link
Member

Yes, #39 may have new bugs, but they should at least be different than this ;)

BTW, still planning some additional cleanups to #39 as well...

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