Nothing more fun than reading the source code :))
I monkey fixed the source code of the Websocket client library so that it can receive the header as a normal parameter in the initializer, for example:
ws = websocket.WebSocketApp("ws://localhost:9999/track", on_open = on_open, on_message = on_message, on_error = on_error, on_close = on_close, header = {'head1:value1','head2:value2'} )
This can be done by editing 3 lines in the source code of the websocket.py library:
1- Add a header parameter:
#
2- Then pass self.header to the websocket connection method as a header parameter, for example:
#
Actually, I tried to import the WebSocketApp class, but it did not work, since the whole websocket.py module is interdependent, that I found that I import a lot of things to make it work, fixing monkeys is easier and more reliable in this case.
For everything, enjoy using the revised library with all the necessary headers.
securecurve
source share