Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] web socket getParameter url encoding issue

Hi guys,

I tried to create my websocket object with my own WebSocketCreator. The connect url has a couple of query parameters, one of them contains a base64 encoded HMAC string.
The problem is, the HMAC string sometimes contains '+', I encoded it as '%2B' in the query parameter. 

e.g, ws://localhost/api?hmac=He%2BB3gwJBRGleMb02i8RMvhpHTo%3D

When I get the value from the WebSocketCreator, the encoded '%2B' becomes space. I guess it's wrongly decoded twice, it's first decoded as '+', then decoded as space. Below is the test code:

    public Object createWebSocket(UpgradeRequest request, UpgradeResponse repsponse) {
            Map<String, String[]> parameters = request.getParameterMap();
            String hmacFromQuery = parameters.get("hmac")[0];

But it works with servlet, e.g, http://localhost/test?hmac=He%2BB3gwJBRGleMb02i8RMvhpHTo%3D
You will get the correct '+' in the query string.

I searched eclipse bug database but did not find any related bugs about this. Does anybody encounter the same problem?

Daniel Wu
Sent with Sparrow

Back to the top