-
Notifications
You must be signed in to change notification settings - Fork 319
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
Body is blank when response has no Content-Length
#45
Comments
It's worth noting here that the socket content after the request has been made is:
Note the chunked encoding. In chunked encoding, one can't read |
You might take a look at some of the existing discussion of this issue on #28 and #39. I don't see a specific ticket for this problem still open for this issue though (besides those tickets, which are vicariously related). tl;dr: yes, the logic is buggy, it's the result of not enough diligence in merging patches, and at this point I was hoping to address it via a rewrite I haven't had enough time to complete. That said, an interim fix is probably in order. |
I'll have to pull it down in test it, but it seems that this will just mean the body will be nil instead of empty string, no? Definitely better than an empty string semantically, but unfortunately doesn't help me here. I'll have a look at those #39 too to see if there is anything I can do to help. |
Yep, #28 is not a fix :( |
I suppose this also affects chunked encoded response, am I wrong ? |
so chunked response should work ? I will have a look again at my code tomorrow it may be on my side then. |
Yes, and you can stream the chunks using |
ok I got it, the latest stable release is so far behind master that ResponseBody does not even exists in it xD |
As per RFC 2616 section 4.4,
Content-Length
is not a required header in responses. I'm using The HTTP Gem with a server that doesn't always send aContent-Length
header.In these cases, the body content is
""
. Combined withaccept(:json)
, this usually meansA JSON text must at least contain two octets! (JSON::ParserError)
exception.See how Curl handles this:
With The HTTP Gem:
A gander at the code shows that this is because
@body_remaining
is derived entirely from the presence of aContent-Length
header. In some (all?) conditions, if@body_remaining
isnil
, the body is not read.The text was updated successfully, but these errors were encountered: