GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Discard the following HttpContent for preflight request by skyguard1 · Pull Request #15941 · netty/netty Conversation
|
|
hmm... I don't think this is correct. We either need to always pass down a |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
However, for preflight requests, the HttpRequest is not being passed down, but the LastHttpContent is. Did I missing something? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@skyguard1 I am just saying we either always need to pass down the request + last content or never.. it always needs to be the combination or none at all. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Preflight (OPTIONS + ACRM) is not a business request; it's merely a control request used internally by the browser to retrieve CORS metadata. Therefore, the business logic should never: receive the preflight HttpRequest receive its HttpContent/LastHttpContent. So, for preflight requests, if you don't pass the HttpRequest, you should also not pass the LastHttpContent. This PR is essentially discarding the LastHttpContent for preflight requests, so I don't know what I'm missing. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@skyguard1 What I am saying is that I don't think this should be configurable at all... |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I got it. So you think the flag should be removed, but this fix is valid. Right? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
My idea is to first minimize changes through the configuration, and then remove the flag after the release when users have configured and validated the behavior of discarding LastHttpContent. This satisfies the principle of minimal changes. Of course, we could also directly delete the flag to perform this fix. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
imho we should just fix it and not have the configuration API. As this is just another API that we need to keep. We could have a system property to fallback to the old behavior but I am not sure this is needed at all. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Agreed. Then I will delete this configuration. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Signed-off-by: skyguard1 <[email protected]>
|
Done |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…uest is forwarded Signed-off-by: skyguard1 <[email protected]>
There was an error while loading. Please reload this page.
…HandlerTest.java Co-authored-by: Norman Maurer <[email protected]>
…HandlerTest.java Co-authored-by: Norman Maurer <[email protected]>
…HandlerTest.java Co-authored-by: Norman Maurer <[email protected]>
…HandlerTest.java Co-authored-by: Norman Maurer <[email protected]>
|
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Almost there... Please also update the PR description etc to reflect what is actual done now
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
|
|
||
| @Test | ||
| public void allowPrivateNetwork() { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
nit: This seems to be not related to the PR
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yes. But I found this allowPrivateNetwork is missing for unit test, maybe remove this?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
just do it in a separate PR
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| assertFalse(ch.writeInbound(preflight)); | ||
| ReferenceCountUtil.release(ch.readOutbound()); | ||
|
|
||
| LastHttpContent first = LastHttpContent.EMPTY_LAST_CONTENT; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
nit: You might also want to test with one non-empty one as it should be the same behavior
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Signed-off-by: skyguard1 <[email protected]>
…nt' into fix_cors_handler_last_http_content
There was an error while loading. Please reload this page.
Signed-off-by: skyguard1 <[email protected]>
|
@skyguard1 thanks! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Motivation: HttpServerCodec always constructs an `EmptyLastHttpContent` and passes it to the Handler chain when processing OPTIONS requests, The `EmptyLastHttpContent` propagate through the handler chain. However, the CORS handler might still propagate the EmptyLastHttpContent to downstream handlers via fireChannelRead(), causing subsequent handlers to receive only this empty content and lose access to the original request URL. Because `CorsHandler` does not consume this message, it calls `ctx.fireChannelRead(msg)` for the EmptyLastHttpContent. Downstream handlers then observe: No HttpRequest A LastHttpContent with empty content This often breaks other handlers that rely on receiving the `HttpRequest` first or expect consistent HTTP message. This PR fixes an issue in `CorsHandler` where, after handling a CORS preflight (OPTIONS) request, the handler still propagates the subsequent `EmptyLastHttpContent` sent by the `HttpServerCodec` to downstream handler. Modification: - `CorsHandler` track handled preflight and consume the following HttpContent, LastHttpContent until the next HttpRequest is forwarded instead of firing it downstream. - Add tests Result: Fixes #15148 It also improves compatibility with application frameworks and routing handlers that expect well-formed HTTP request/response flows. --------- Signed-off-by: skyguard1 <[email protected]> Co-authored-by: xingrufei <[email protected]> Co-authored-by: code-xing_wcar <[email protected]> Co-authored-by: Norman Maurer <[email protected]>
Motivation: HttpServerCodec always constructs an `EmptyLastHttpContent` and passes it to the Handler chain when processing OPTIONS requests, The `EmptyLastHttpContent` propagate through the handler chain. However, the CORS handler might still propagate the EmptyLastHttpContent to downstream handlers via fireChannelRead(), causing subsequent handlers to receive only this empty content and lose access to the original request URL. Because `CorsHandler` does not consume this message, it calls `ctx.fireChannelRead(msg)` for the EmptyLastHttpContent. Downstream handlers then observe: No HttpRequest A LastHttpContent with empty content This often breaks other handlers that rely on receiving the `HttpRequest` first or expect consistent HTTP message. This PR fixes an issue in `CorsHandler` where, after handling a CORS preflight (OPTIONS) request, the handler still propagates the subsequent `EmptyLastHttpContent` sent by the `HttpServerCodec` to downstream handler. Modification: - `CorsHandler` track handled preflight and consume the following HttpContent, LastHttpContent until the next HttpRequest is forwarded instead of firing it downstream. - Add tests Result: Fixes #15148 It also improves compatibility with application frameworks and routing handlers that expect well-formed HTTP request/response flows. --------- Signed-off-by: skyguard1 <[email protected]> Co-authored-by: xingrufei <[email protected]> Co-authored-by: code-xing_wcar <[email protected]> Co-authored-by: Norman Maurer <[email protected]>
) Motivation: HttpServerCodec always constructs an `EmptyLastHttpContent` and passes it to the Handler chain when processing OPTIONS requests, The `EmptyLastHttpContent` propagate through the handler chain. However, the CORS handler might still propagate the EmptyLastHttpContent to downstream handlers via fireChannelRead(), causing subsequent handlers to receive only this empty content and lose access to the original request URL. Because `CorsHandler` does not consume this message, it calls `ctx.fireChannelRead(msg)` for the EmptyLastHttpContent. Downstream handlers then observe: No HttpRequest A LastHttpContent with empty content This often breaks other handlers that rely on receiving the `HttpRequest` first or expect consistent HTTP message. This PR fixes an issue in `CorsHandler` where, after handling a CORS preflight (OPTIONS) request, the handler still propagates the subsequent `EmptyLastHttpContent` sent by the `HttpServerCodec` to downstream handler. Modification: - `CorsHandler` track handled preflight and consume the following HttpContent, LastHttpContent until the next HttpRequest is forwarded instead of firing it downstream. - Add tests Result: Fixes #15148 It also improves compatibility with application frameworks and routing handlers that expect well-formed HTTP request/response flows. Signed-off-by: skyguard1 <[email protected]> Co-authored-by: skyguard1 <[email protected]> Co-authored-by: xingrufei <[email protected]> Co-authored-by: code-xing_wcar <[email protected]>
|
It is my pleasure |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
) Motivation: HttpServerCodec always constructs an `EmptyLastHttpContent` and passes it to the Handler chain when processing OPTIONS requests, The `EmptyLastHttpContent` propagate through the handler chain. However, the CORS handler might still propagate the EmptyLastHttpContent to downstream handlers via fireChannelRead(), causing subsequent handlers to receive only this empty content and lose access to the original request URL. Because `CorsHandler` does not consume this message, it calls `ctx.fireChannelRead(msg)` for the EmptyLastHttpContent. Downstream handlers then observe: No HttpRequest A LastHttpContent with empty content This often breaks other handlers that rely on receiving the `HttpRequest` first or expect consistent HTTP message. This PR fixes an issue in `CorsHandler` where, after handling a CORS preflight (OPTIONS) request, the handler still propagates the subsequent `EmptyLastHttpContent` sent by the `HttpServerCodec` to downstream handler. Modification: - `CorsHandler` track handled preflight and consume the following HttpContent, LastHttpContent until the next HttpRequest is forwarded instead of firing it downstream. - Add tests Result: Fixes #15148 It also improves compatibility with application frameworks and routing handlers that expect well-formed HTTP request/response flows. Signed-off-by: skyguard1 <[email protected]> Co-authored-by: skyguard1 <[email protected]> Co-authored-by: xingrufei <[email protected]> Co-authored-by: code-xing_wcar <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
HttpServerCodec always constructs an "EmptyLastHttpContent" and passes it to the Handler chain when processing OPTIONS requests
There was an error while loading. Please reload this page.