amphp / websocket-client

Async WebSocket client for PHP based on Amp.
https://amphp.org/websocket-client
MIT License
147 stars 17 forks source link

Do not automatically set the origin header in websocket connections #37

Closed iggyvolz closed 2 years ago

iggyvolz commented 2 years ago

The v2 branch is currently setting the origin header even if not explicitly requested: https://github.com/amphp/websocket-client/blob/b2ce5a8a7a4a47e253f1bb5dd6539cfd2488e201/src/Rfc6455Connector.php#L108-L114 However, this causes issues for web services that do not expect an origin header: https://github.com/discord/discord-api-docs/issues/4312#issuecomment-1040660416. This could also be implemented as an option in Amp\Websocket\Options (https://github.com/amphp/websocket/blob/9d6e010f2367ddd19d7050f1755f7e8684e83c56/src/Options.php) to retain the current behavior by default.

trowski commented 2 years ago

Forgot about this – sorry. This behavior is in v1 as well, but that will need an (deprecated) option added on Handshake or the connector to optionally remove it.