Skip to content

Commit 07a8654

Browse files
author
yuanadmin
committed
fix 403 forbidden when dial with CDN IP with Custom SNI
1 parent 157f790 commit 07a8654

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/websockets/legacy/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,12 @@ async def handshake(
278278
279279
"""
280280
request_headers = Headers()
281-
282-
request_headers["Host"] = build_host(wsuri.host, wsuri.port, wsuri.secure)
281+
# fix 403 forbidden when dial with CDN IP with Custom SNI
282+
if extra_headers["Host"]:
283+
request_headers["Host"] = extra_headers["Host"] # key point
284+
else:
285+
request_headers["Host"] = build_host(wsuri.host, wsuri.port, wsuri.secure)
286+
# request_headers["Host"] = build_host(wsuri.host, wsuri.port, wsuri.secure)
283287

284288
if wsuri.user_info:
285289
request_headers["Authorization"] = build_authorization_basic(

0 commit comments

Comments
 (0)