MyTetra Share
Делитесь знаниями!
Sending custom headers in websocket handshake
Время создания: 06.08.2018 10:19
Текстовые метки: websocket python
Раздел: WebSocket
Запись: Velonski/mytetra-database/master/base/153353277493xgn93dvj/text.html на raw.githubusercontent.com

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://echo.websocket.org/", headers={"User-Agent": "MyProgram"})


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


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