问题描述
我在我的 javascript 客户端中通过 SockJS 使用 stomp.js.我正在使用
I'm using stomp.js over SockJS in my javascript client.I'm connecting to websocket using
stompClient.connect({}, function (frame) {
stomp over sockJS 连接有 2 个 http 请求:
stomp over sockJS connection has 2 http requests:
- 请求/info
- http 升级请求
客户端发送所有 cookie.我还想发送自定义标头(例如 XSRF 标头),但没有找到方法.将不胜感激任何帮助.
the client sends all cookies. I would like to also send custom headers (e.g. XSRF header) but didn't find a way to do that. Will appreciate any help.
推荐答案
@Rohitdev所以基本上你不能使用 stompClient 发送任何 HTTP 标头,因为 STOMP 是 websockets 的层,并且只有当 websockets 握手发生时,我们才有可能发送自定义标头.所以只有 SockJS 可以发送这个标头,但由于某些原因不要这样做:https://github.com/sockjs/sockjs-client/issues/196
@RohitdevSo basically you can't send any HTTP headers using stompClient, because STOMP is layer over websockets, and only when websockets handshake happen we have possibility to send custom headers.So only SockJS can send this headers, but for some reasons don't do this: https://github.com/sockjs/sockjs-client/issues/196
这篇关于WebSocket Stomp over SockJS - http 自定义标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!