-
-
Notifications
You must be signed in to change notification settings - Fork 145
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
RequestBodyBufferMiddleware: 411 No Content Length for GET requests? #232
Comments
Thanks for reporting! A normal Requests that do use a body but do specify a Does this help with the issue you're seeing? Otherwise, can you provide some code for us to reproduce the problem you're seeing? Thank you! |
@clue here we go. It seems like an odd request that GuzzleHttp produces but thats what seems to cause the problem. The request uses request:
response:
under the hood the It seems this is a special case where a chunked body of length 0 (or really a request that cannot have a body?) is removed and length 0 needs be kept? Took me 4 hours now to get there- too tired to look for a fix... For time being this is my workaround, probably invalid:
|
@andig Thanks for digging into this and confirming my above assertion 👍 Apparently your above request uses the This is indeed a valid request, but as stated above is currently not supported by the I'm not sure how relevant this issue is actually in the wild which is why we chose to not implement this in the first step. I suppose we would be happy to re-evaluate this and accept PRs 👍 As an alternative, have you tried explicitly assigning a I hope this helps 👍 |
The root cause for this issue in my setup is actually symfony/symfony#24437. The general behaviour of producing this kind of valid but ugly request is due to Symfony returning a stream when it shouldn't. From what I understand it shouldn't be too difficult- if you accept potential memory consumption- to buffer requests of unknown length. I'll try to look into this, might be beyond my skill due to the involved stream magic. |
I'm toying with the idea of buffering chunked requests limited by buffer size (
|
@andig @clue Imho we have a few options here:
My main concern is that this might be very common behavior among HTTP clients and we would be rejecting their requests thus blocking a possible big percentage of clients out there. In the end I want our users not to have to worry about these kind of things. /cc @jsor what do you think? |
I fully agree. Even more so as large parts of the infrastructure like the From what I've looked into 1)/2) needs collaboration of the server since it already removes those requests. This seems a bit ugly right now since the behaviour cannot be controlled solely by middleware. So also 3) would need help by the I've opened #235 for sake of discussion with what I've got so far. |
Does your client send a correct body in that case, so |
I'll need to double-check the Guzzle internals for that case. Good question how to handle it if it doesn't? |
If it doesn't, then Guzzle / Symfony / whatever needs a bug fix anyway. The client could also just check the first chunk of the stream end see whether the stream is already at EOF at that point before sending |
@kelunik Symfony returns
|
@andig What happens if you change the order of the |
If I |
You obviously have to read at least one byte. ;-) |
Or we could make this scenario work as the request is legal ;) I've pushed two more commits to #235 that handle the |
Update I've updated this once more to move the entire body decoding and handling logic to the ping @WyriHaximus for another look |
That's of course preferred. |
@andig Re: #120 (comment) I've had a call with @clue earlier this week regarding this and other issues and we're going to make one minor change to |
@WyriHaximus any solution you think fit is fine with me. Regarding reactphp/promise-stream#3 and it's use I found it useful in #235 to distinguish between "any type of stream exception" and
I'm happy that I can contribute smaller things and just a bit impatient for the finished server ;)
I changed that because it was required with my approach. In hindsight I thought it might even be useful for extensibility but that could also come through subclassing the server rather than middlewares. And how often would you need to implement other transfer encodings... I'd be happy to update this PR when reactphp/promise-stream#3 is in. |
I'm closing this in favour of #235 which I'll follow up with. |
I'm doing some testing with Guzzle as client and I'm running into unexpected behaviour- 411 instead of qualified response.
In
http/src/Middleware/RequestBodyBufferMiddleware.php
Line 35 in abdf36e
Content-length
is not set. According to https://stackoverflow.com/questions/8540931/what-is-the-correct-content-length-to-set-for-a-get-request this requirement should not be necessary.IMHO that would mean that the 411 should not be returned for GET requests and instead 0 assumed.
cc @WyriHaximus
The text was updated successfully, but these errors were encountered: