long-pollingcometdbayeux

How do I get the response object in a bayeux server response in CometD


I am trying to customize the response of a bayeux server response so that i can add some header parameters before sending it back to UI. I am able to add header values in the request using customize method in a LongPollingTransport. Much help needed.


Solution

  • CometD tries to abstract away from the underlying protocol.

    When you use WebSocket, for example, the concepts of request headers and response headers simply do not exist anymore.

    As such, it is way better that if you have additional information to send to the client, well that additional information should go in the CometD messages rather than in HTTP headers.

    Furthermore, when using HTTP as a transport, a single HTTP response may carry multiple messages, so it is not clear to what CometD message the additional information would refer to.

    Your question is too generic (does not say why you want to add headers, does not say what specific header, etc.) to get a precise answer, but bottom line is that you typically don't want to use HTTP headers with CometD.