You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "reiern70 (via GitHub)" <gi...@apache.org> on 2026/10/19 18:51:37 UTC

[PR] Keep the Servlet header contract in the WebSocket request copies [wicket]

reiern70 opened a new pull request, #1689:
URL: https://github.com/apache/wicket/pull/1689

   Closes #1688
   
   `ServletRequestCopy` and `JavaxUpgradeHttpRequest`, the requests Wicket keeps for the life of a WebSocket connection, did not follow the Servlet rules for headers. Thanks @guidecom-ze for the report and the analysis.
   
   ### What was wrong
   
   - Lookups used the exact name the container reported, so a lowercase `origin` (HTTP/2, many proxies) was not found as `Origin`, and `WebSocketConnectionOriginFilter` rejected the connection.
   - `ServletRequestCopy` handed out the enumerations of the request it copied, which can be read once: a second `getHeader` returned the next value or `null`, a second `getHeaders` a spent enumeration. `getIntHeader` consumed them as well and threw a `NullPointerException` for an absent header. `getLocales` had the same problem.
   - `getHeaders` returned `null` for an absent header (and `JavaxUpgradeHttpRequest.getHeaderNames` when there were none). `ServletWebRequest.getHeaders` dereferences it, so `WebRequest#getHeaders` on a WebSocket request threw a `NullPointerException`.
   
   ### What it does now
   
   - Both classes copy the headers when they are created, into a map whose names compare case-insensitively, and return a fresh enumeration on every read, empty rather than `null`.
   - `ServletRequestCopy.getIntHeader` returns `-1` for an absent header, and the locales are copied up front.
   - A name the copied request reports in more than one case (Jetty does) is copied once, because that request's `getHeaders` already returns all of its values. `JavaxUpgradeHttpRequest` merges the values of handshake map keys that differ only in case.
   - `getHeaderNames` lists each name once, in case-insensitive alphabetical order.
   
   Only private fields change: no API change, nothing to migrate.
   
   ### Not in this PR
   
   - `ServletRequestCopy.getDateHeader` always returns 0.
   - `JavaxUpgradeHttpRequest.getLocale()` and `getLocales()` return `null`, and its `getIntHeader` and `getDateHeader` do not follow the Servlet rules for absent or malformed values.
   
   ### Backport
   
   Both files are identical on `wicket-10.x`, so the commit cherry-picks cleanly there; `wicket-9.x` would need adapting. Which lines it goes to is still open.
   
   ### Tests
   
   - `ServletRequestCopyTest` (wicket-native-websocket-core) and `JavaxUpgradeHttpRequestTest` (wicket-native-websocket-javax): 10 tests, all of which fail on master. One copies an upgrade request with a lowercase `origin` and runs it through `WebSocketConnectionOriginFilter`.
   - `mvn clean verify -Pjs-test` is green.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@wicket.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Keep the Servlet header contract in the WebSocket request copies [wicket]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #1689:
URL: https://github.com/apache/wicket/pull/1689#issuecomment-6274909997

   ## [Codecov](https://app.codecov.io/gh/apache/wicket/pull/1689?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `85.18519%` with `4 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 62.11%. Comparing base ([`2a70207`](https://app.codecov.io/gh/apache/wicket/commit/2a7020733f7d8f439cd7968cff03a0dacaf60600?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`06e1664`](https://app.codecov.io/gh/apache/wicket/commit/06e1664d7997aff80d779f12972601131f5994ff?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #1689      +/-   ##
   ============================================
   + Coverage     61.96%   62.11%   +0.14%     
   - Complexity    11285    11337      +52     
   ============================================
     Files          1250     1250              
     Lines         48437    48420      -17     
     Branches       6796     6794       -2     
   ============================================
   + Hits          30014    30074      +60     
   + Misses        15729    15647      -82     
   - Partials       2694     2699       +5     
   ```
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@wicket.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Keep the Servlet header contract in the WebSocket request copies [wicket]

Posted by "reiern70 (via GitHub)" <gi...@apache.org>.
reiern70 merged PR #1689:
URL: https://github.com/apache/wicket/pull/1689


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@wicket.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org