-
Notifications
You must be signed in to change notification settings - Fork 255
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
RxNetty HTTP client protocol always sends a empty message-body for GET method. #520
Comments
Hey Ken, looks like a duplicate of #470. Short version is that the RFC seems to conflate message body and payload (and null-ability and emptiness - is an zero length body the same as a single zero length chunk?) w.r.t. chunked encoding so it's ambiguous as whether RxNetty is 'correct' (I tend to side with Nitesh on the loose interpretation. Of course this doesn't help if Chrome is dying on you). on the tech side, from Nitesh:
|
Thanks @kurzweil for the detailed analysis ❤️ @jamesgorman2 thanks for pitching OSS FTW ❤️ Since I have now seen an example of things that behave badly with such requests, its time to atleast put a workaround 😄 I think if a |
Setting the |
EDIT: I've been working in .Net land recently and just realised Given there is a mechanism to suppress the message body with If you had something like
and
with
and
to flip between writable and un-writable requests and set/unset the You could then have:
and someone with an impolite API to call could use
Not sure about an equivalent for the server responses (ie to make getting empty responses easier for 201, etc) This is all off the top of my head, so it needs some polishing and might make more sense in code. @NiteshKant Does this fit in with where you're taking RxNetty? I can work up a PR in the week for it if you like |
@jamesgorman2 I was thinking more like an implementation detail that does not write a body if For this workaround, the usage will just be: HttpClient.newClient(serverAddress)
.createGet("/hello")
.setHeader(HttpHeaderNames.CONTENT_LENGTH, 0) instead of HttpClient.newClient(serverAddress)
.createGet("/hello") I would think of the change be in |
I can certainly look at this. I'll put something in for the basic solution you proposed. W.r.t. my proposal, it was around (a) providing sensible defaults for GET, (b) providing a fluent way to create explicit empty messages, and (c) preventing people thinking they can write to the object after making an empty message. These are in-effect separate from actually ensuring the body is empty so I'm happy to leave them (though I might still play around with some of the ideas anyway - I have a related problem with types for some stream-wise JSON handling I'm working on). |
Absolutely, I will be happy to look at your changes! |
Update `RawRequest` and `HttpServerResponseImpl` so they return `content-length: 0` and an empty body when no writes are made to `HttpClientRequest` and `HttpServerResponse` respectively. This also adds some regression level tests against the bytes sent and received from the server.
Update `RawRequest` and `HttpServerResponseImpl` so they return `content-length: 0` and an empty body when no writes are made to `HttpClientRequest` and `HttpServerResponse` respectively. This also adds some regression level tests against the bytes sent and received from the server.
Update `RawRequest` and `HttpServerResponseImpl` so they return `content-length: 0` and an empty body when no writes are made to `HttpClientRequest` and `HttpServerResponse` respectively. This also adds some regression level tests against the bytes sent and received from the server.
Turns out didn't need a complicated solution and the building blocks were there already. |
So looks like adding a header of @jamesgorman2 I think your PR still makes sense as it is solving a different usecase which is adding |
* Empty body for zero length payloads (#470, #520) Update `RawRequest` and `HttpServerResponseImpl` so they return `content-length: 0` and an empty body when no writes are made to `HttpClientRequest` and `HttpServerResponse` respectively. This also adds some regression level tests against the bytes sent and received from the server.
Fixed via #522 |
I am using RxNetty to implement a HTTP client which performs HTTP GET and WebSocket operations. Currently I'm using this client to interact with the stock remote debugging interface implemented as a webserver internal to the Chrome Browser and have discovered that RxNetty expresses a bug within the Chrome Browser that immediately causes it to segmentation fault while upgrading to the WebSocket protocol
I believe this might be because the RxNetty client isn't explicitly following the RFC7230 where
HTTP-messages
may have amessage-body
but are not required in all cases and in cases of the GET method should not have amessage-body
. Obviously, the Chrome Browser shouldn't crash over this subtle protocol infringement, but I don't think RxNetty should be explicitly sending empty bodies either. (Roy Fielding has an opinion about GET methods with message-bodies)I've been able to for RxNetty not to add the explicit message-body by temporarily commenting out rxnetty-http/src/main/java/io/reactivex/netty/protocol/http/client/internal/RawRequest.java#L180
which enables Chrome to continue with the upgrade and not crash. I've captured a before and after look of the protocol exchange when commenting out the line.
Any thoughts?
Much appreciated,
Ken
The text was updated successfully, but these errors were encountered: