File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,15 @@ def test_parse_wss_scheme_with_query_string(self):
104
104
self .assertEqual (c .resource , "/?token=value" )
105
105
self .assertEqual (c .bind_addr , ("127.0.0.1" , 443 ))
106
106
107
+ def test_overriding_host_from_headers (self ):
108
+ c = WebSocketBaseClient (url = "wss://127.0.0.1" , headers = [("Host" , "example123.com" )])
109
+ self .assertEqual (c .host , "127.0.0.1" )
110
+ self .assertEqual (c .port , 443 )
111
+ self .assertEqual (c .bind_addr , ("127.0.0.1" , 443 ))
112
+ for h in c .handshake_headers :
113
+ if h [0 ].lower () == "host" :
114
+ self .assertEqual (h [1 ], "example123.com" )
115
+
107
116
@patch ('ws4py.client.socket' )
108
117
def test_connect_and_close (self , sock ):
109
118
Original file line number Diff line number Diff line change @@ -265,6 +265,7 @@ def handshake_headers(self):
265
265
if self .extra_headers :
266
266
headers .extend (self .extra_headers )
267
267
268
+ # keep old logic if no overriding Host in headers
268
269
if not any (x for x in headers if x [0 ].lower () == 'host' ) and \
269
270
'host' not in self .exclude_headers :
270
271
headers .append (('Host' , '%s:%s' % (self .host , self .port )))
You can’t perform that action at this time.
0 commit comments