vi / websocat

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

add cookies with websocat #92

Closed mmm286 closed 4 years ago

mmm286 commented 4 years ago

Hi! I'm trying to "translate" a curl request with websocat because the request connect with websocket using cookies and then I need to pass some messages. The curl sentence use option -b. Is posible to make this with websocat? Thanks!

vi commented 4 years ago

Currently you need to manually translate curl -b to equivalent curl -H, then use Websocat's -H option.

If there is enough popular demand for this feature, I can implement a --cookie parameter that does curl-like mapping to -H within Websocat (short name -b is busy).

quarky42 commented 3 years ago

In short: I could use this feature. I will lok into what the -H curl equivalent means. I'm not familiar with that flag offhand, but guessing that you're pulling the cookie reference out of the dumped file and pasting it into the command line itself as a header to be passed. I can probably do that in the meantime if my guess isn't too far off.

Just to understand my use case a little better: I have to login to a piece of hardware by passing it a username and password. With curl, I'm using the -d command and some XML in quotes to do this. I use -D to save the response that includes the cookie as a file. At this point I'm logged in for as long as that cookie is good. (10 minutes maybe)

I issue all my following curl commands to this piece of hardware with the -b pointing to that cookie file and get the responses for the queries I'm trying to execute. Being able to do this interactively through websockets and being able to subscribe to a query would be very helpful. I'll check out that -H stuff. Thanks.