How to specify a request body?
How can we supply an optional body, such as a JSON document, to include in a WebSocket request?
A body with HTTP GET request?
Maybe it is possible to implement, but what is the use case? Can one supply a body when doing WebSocket connection from a browser?
In typical protocols there may be a body in separate HTTP POST request, which returns some token, which is then used for body-less HTTP GET WebSocket connection request. Example of such protocol is Google Chrome remote debugging interface.
Some GraphQL servers (e.g. https://github.com/99designs/gqlgen) allow specifying a subscription query in the body which results in upgrading the connection to websocket.
Is it possible to send body-containing such WebSocket request from a browser?
Currently it is problematic to do such upgrade from WebSocat.
If you can do such upgrade using some external program (e.g. like curl -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Sec-WebSocket-Key: IQZUbZm5XwEFrOVT8+3uUw==" , but bidirectional), you can use pre-upgraded WebSocket connection with Websocat using a command line like this:
websocat -t - ws-lowlevel-client:cmd:'your_connect_and_upgrade_command'