Skip to content

Conversation

vukasin
Copy link

@vukasin vukasin commented May 16, 2012

hi,

i am using wss client to access a server which requires me to send credentials (basic). that involves adding headers to the request which the current interface does not allow. i have changed a few constructors by adding an additional parameter (with a default value to avoid breakage) which allows you to add any number of custom http headers to your request. that has worked very nicely for me so i thought i'd share it.

i have also changed the default port for wss in the tornado client from 80 to 443.

vukasin added 3 commits May 16, 2012 13:04
add the possibility to add headers to the HTTP request. this is useful
when sending an authentication header along with the request
set default port for was to 443 instead of 80
Lawouach added a commit that referenced this pull request Jun 21, 2012
@EliAndrewC
Copy link
Contributor

For what it's worth, you can add custom headers today when you subclass one of the ws4py.client classes, which you have to do to override received_message anyway, e.g.

from ws4py.client.threadedclient import WebSocketClient

custom_headers = [('Custom-Header', 'custom header value')]

class Client(WebSocketClient):
    def received_message(self, message):
        print("received {}".format(str(message)))

    @property
    def handshake_headers(self):
        return super(Client, self).handshake_headers + custom_headers

@Lawouach Lawouach closed this in caf7aa7 Sep 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants