如何在Javascript中访问Websocket响应头? [英] How to access Websocket Response Headers in Javascript?

查看:190
本文介绍了如何在Javascript中访问Websocket响应头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从javascript websocket连接访问响应头。
有没有办法访问这些响应头?
或者至少是响应代码?

I need to access the response header from a javascript websocket connection. Is there any way to access these response header? Or at least the response code?

我只能访问onclose,onerror,onopen的事件,其中有一些(不可用 - 用于我的目的)属性!

I only have access to the event of onclose, onerror, onopen with a few (unusable - for my purposes) properties!

推荐答案

你做不到。目前没有任何功能。 WebSockets的重点不是HTTP通信。 HTTP仅用于握手。

You can't. There is no functionality for that at the moment. The point of WebSockets is not HTTP communication. HTTP is only used for the handshake.

https://developer.mozilla.org/en-US/docs/Web/API/WebSocket

这篇关于如何在Javascript中访问Websocket响应头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆