cometdbayeux

How to add a request header in Bayeux Client Request?


I am using the Bayeux Java Client, and I am trying to add a request header for all the requests made to the server, including the handshake request.

Currently I am using :

   mTransport = new LongPollingTransport(options, httpClient) {
        @Override
        protected void customize(ContentExchange exchange) {
            super.customize(exchange);
            if (mCrumb != null) {
                exchange.addRequestHeader("Header Key", "Header value");
            }
        }
    };

    mClient = new BayeuxClient(HANDSHAKE_URL, mTransport);

Is this the right way? I am not able to get it to work? Thanks,


Solution

  • That is the right way to do it.

    In the CometD test suite there is a test that performs what you are doing.