MyTetra Share
Делитесь знаниями!
Sending custom headers in websocket handshake
Время создания: 06.08.2018 10:19
Текстовые метки: websocket python
Раздел: WebSocket

How to send custom headers in the first handshake that occurs in the WebSocket protocol?

I want to use custom header in my initial request "**X-Abc-Def : xxxxx"

WebSocket clients are Python & Android client.

You need to mention which WebSocket clients you are using. A quick google search showed me at least two different ones for android.

In the python websocket-client you can indeed pass custom headers easily - there's a keyword argument headers available for this; see the following example from the docs:

conn = create_connection("ws://", headers={"User-Agent": "MyProgram"})

"headers" is wrong key word, should be "header". the following code works for me. ``` conn = create_connection("ws://", header={"User-Agent": "MyProgram"}) ``` – wazhao Jul 7 '17 at 1:55

Так же в этом разделе:
MyTetra Share v.0.53
Яндекс индекс цитирования