vi / websocat

Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions
MIT License
6.72k stars 257 forks source link

Support HTTP Redirection at Handshake #173

Open misery opened 1 year ago

misery commented 1 year ago

Hi!

I like to request that the server can send a http redirect (3xx) and websocat allows to handle this.

It seems WebSocket allows this: https://www.rfc-editor.org/rfc/rfc6455

1.  If the status code received from the server is not 101, the
       client handles the response per HTTP [[RFC2616](https://www.rfc-editor.org/rfc/rfc2616)] procedures.  In
       particular, the client might perform authentication if it
       receives a 401 status code; the server might redirect the client
       using a 3xx status code (but clients are not required to follow
       them), etc.  Otherwise, proceed as follows.
vi commented 1 year ago

At least printing of Location: in a more user-friendly way can be an option for quick implementation.

Proper redirects may be more of Websocat3 material.

vi commented 9 months ago

In Websocat 1.12:

$ websocat  ws://127.0.0.1:7780/
websocat: WebSocketError: WebSocketError: Redirected (302 Found) to http://example.com/
websocat: error running