davsclaus opened a new pull request, #29845:
URL: https://github.com/apache/camel/pull/29845

   ## Description
   
   [CAMEL-26922](https://issues.apache.org/jira/browse/CAMEL-26922)
   
   With the `events` init-param of `CamelWebSocketServlet` set to `true`, the 
camel-atmosphere-websocket consumer routes an exchange for the open, close and 
error events of each websocket connection, with the query parameters as 
headers. These parameters did not belong to the connection of the event:
   
   - `WebsocketConsumer.service()` parsed the query string of every HTTP 
request the servlet handled into one field of the consumer, and every event 
read that field. A close or error event therefore had the parameters of the 
last HTTP request to the endpoint path, not those of its own connection.
   - With the JSR 356 transport, which Atmosphere uses on current servlet 
containers (and in the tests on Jetty), the websocket handshake does not go 
through `service()`, so the parameters of the connection never reached its 
events.
   - Names and values were not URL-decoded.
   
   ## Change
   
   - `WebsocketHandler.onOpen` reads the query string from the 
`AtmosphereRequest` of the connection (`webSocket.resource().getRequest()`, set 
on both transports), parses it once and keeps it by connection key. The open, 
close and error events of that connection use it; it is dropped when the 
connection closes.
   - `WebsocketConsumer`: the shared field and its assignment in `service()` 
are removed; `sendEventNotification` takes the parameters of the connection as 
a third argument; `getQueryMap` URL-decodes names and values (UTF-8, `+` as 
space, text that is not valid URL encoding is kept as is). The header filter 
strategy is applied as before.
   - Component doc: a new "Connection Events" section describes the `events` 
init-param, the event headers and the query parameter headers.
   - Upgrade guide 4.24: a note on the changed event headers and the new 
`sendEventNotification` signature.
   
   ## Tests
   
   - New `WebsocketEventQueryParameterTest` (asserts through a mock endpoint):
     - `openEventHasQueryParametersOfItsConnection`: two connections with 
different parameters, each open event has the parameters of its own connection.
     - `closeEventHasQueryParametersOfItsConnection`: the close event of the 
first connection has its parameters after a second connection opened.
     - `plainHttpRequestDoesNotChangeEventHeaders`: a plain HTTP request with 
other parameters between open and close does not change the close event.
     - `queryParameterValuesAreUrlDecoded`.
   - `WebsocketQueryParameterTest.testQueryMapDecodesNamesAndValues`: parser 
cases with encoded names and values and an invalid escape.
   - `WebsocketRoute1WithInitParamTest.testPassParametersWebsocketOnOpen` now 
asserts through a mock endpoint; before, its assertions ran inside a processor, 
so the test passed although the parameters were missing.
   
   All six new or changed tests fail without the change in `WebsocketConsumer` 
and `WebsocketHandler` and pass with it; the module tests pass.
   
   Backport to camel-4.22.x and camel-4.18.x follows, together with the 
tolerant query string parser of CAMEL-26141.
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to