Jetty
  1. Jetty
  2. JETTY-1509

The WebSocket Client should support customized headers

    Details

    • Type: Improvement Improvement
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 8.1.2
    • Fix Version/s: None
    • Component/s: Client
    • Labels:
      None
    • Number of attachments :
      1

      Description

      Add a method getHeaders() to WebSocketClient, just like getCookies(). Then the client has an opportunity to insert specific headers before making the connection. E.g. the header could contain the client specific authentication or identification information, so that the server side can identify which user is trying to connect.

      The change need to modify handshake() method in org.eclipse.jetty.websocket.WebSocketClientFactory.HandshakeConnection a little bit.
      Inesrt the following codes at line 428:
      Map<String, String> headers = _future.getHeaders();
      if (headers != null && !headers.isEmpty()) {
      for (Map.Entry<String, String> entry : headers.entrySet())

      { request.append(entry.getKey()).append(":").append(entry.getValue()).append("\r\n"); }

      }

        Activity

        Hide
        Jan Bartel added a comment -

        Can you take a look?

        Show
        Jan Bartel added a comment - Can you take a look?
        Hide
        Robert Roland added a comment - - edited

        Attached is a patch that implements this behavior as of git head today, for jetty 7.6.5-SNAPSHOT. I need this patch myself right now.

        Show
        Robert Roland added a comment - - edited Attached is a patch that implements this behavior as of git head today, for jetty 7.6.5-SNAPSHOT. I need this patch myself right now.
        Hide
        Jan Bartel added a comment -

        Robert -

        I've moved this bug across to jetty eclipse bugzilla, as jetty moved across to Eclipse some time ago and we're trying to consolidate everything there:

        https://bugs.eclipse.org/bugs/show_bug.cgi?id=396561

        Would you mind reading the Eclipse IP contribution guidelines (http://wiki.eclipse.org/Development_Resources/Handling_Git_Contributions) and if you're happy with them, then reattaching your patch to that issue?

        thanks
        Jan

        Show
        Jan Bartel added a comment - Robert - I've moved this bug across to jetty eclipse bugzilla, as jetty moved across to Eclipse some time ago and we're trying to consolidate everything there: https://bugs.eclipse.org/bugs/show_bug.cgi?id=396561 Would you mind reading the Eclipse IP contribution guidelines ( http://wiki.eclipse.org/Development_Resources/Handling_Git_Contributions ) and if you're happy with them, then reattaching your patch to that issue? thanks Jan

          People

          • Assignee:
            Joakim Erdfelt
            Reporter:
            Daniel Wu
          • Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated: