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
HttpClient fails when response is chunked, but no body is sent #1433
Comments
hi, can you check with current Vert.x 3.3 snapshot ? |
Just retested with the snapshot in https://oss.sonatype.org/content/repositories/snapshots. Still the same problem. |
this response is invalid and it confuses the Netty parser. For Netty a 204 response cannot be chunked so it thinks there is no content whatsoever and the following bytes (the empty chunked message) is interpreted by Netty as an invalid response. To me the server you access is misbehaving. I will try to see if there is a workaround to this, i.e tolerate an 204 response with chunked content header. |
see in HttpObjectDecoder#isContentAlwaysEmpty:
|
@vietj FYI I agree with that the server is misbehaving, already created an issue in that project: Graylog2/graylog2-server#2276 Would be nice at least get a easier to debug error though, it's not very obvious. (I understand this is mostly Netty's fault) |
and it's not possible to override this behavior in Netty as the class HttpClientCodec is final |
so finally I think the problem we can solve is that Vert.x is confused by this behavior because it receives two responses (one is an error response created by invalidMessage) and we should try to make Vert.x handle properly this case at least |
my opinion is that in such case, we should mark the connection as "stale" and try to handle the potential pipelined responses but not put in back in the connection pool. |
will contribute to that tomorrow! |
Great, no hurries though, it's not blocking at all. Good improvement to avoid the same issue for others though :) |
cf also in HttpResponseDecoder:
that generates this new extra response instead of doing a failure. if I remember correctly this behavior has been debated in a Netty issue. |
so when vertx gets such error it should just ignore it, specially if it's a HTTP_1_1 connection. HTTP_1_0 does not do keep-alive, so there is no ambiguity. |
hi, here is a fix for this error: https://github.com/eclipse/vert.x/tree/invalid-http-response in your case you should not receive any error on the request/response as it happens after the http response is received and it should be logged. if you are using pipelining, the pipelined requests should error. in all cases the connection will be closed as considered as unusable. |
Running the same test now gives |
yes, this is expected, as I said before "it should be logged". if you use pipelining, the next request will get the error. |
one idea could be to have this error flow in the HttpConnection handler as it would be interesting to notify as this place too, before logging |
I'm using HttpClient to invoke a third party REST API. Using a curl on the resource in question gives the following:
Vert.x doesn't like the combination of chunked and "no content", which can be reproduced with the test below:
The following exception is thrown.
Switching
setChunked
to false fixes the problem.The text was updated successfully, but these errors were encountered: