Use `surrogateescape` to encode headers on `websockets` implementation
@@ -170,7 +170,7 @@ class WebSocketProtocol(WebSocketServerProtocol):
subprotocols.extend([token.strip() for token in header.split(",")])
asgi_headers = [
- (name.encode("ascii"), value.encode("ascii"))
+ (name.encode("ascii"), value.encode("ascii", errors="surrogateescape"))
for name, value in headers.raw_items()
]
