Skip to main content

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

Sounds like a bug.

What version of Jetty are you testing with?
Seeing the signature of createWebSocket(UpgradeRequest, UpgradeResponse) i think you are on 9.0.5, but I just want to make sure.

Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts

On Sun, Sep 29, 2013 at 10:39 PM, Daniel Wu <daniel.y.woo@xxxxxxxxx> wrote:
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];

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

jetty-users mailing list

Back to the top