lwthiker / curl-impersonate

curl-impersonate: A special build of curl that can impersonate Chrome & Firefox
MIT License
3.47k stars 230 forks source link

Does this project provide a solution for connecting to a web socket? #41

Open NabiKAZ opened 2 years ago

NabiKAZ commented 2 years ago

Does this project provide a solution for connecting to a web socket? For example, I need an example like this in nodejs:

var socket = new WebSocket(url);
socket.onopen = function() {
...
};
socket.onmessage = function(e) {
...
};

The url in that example is on cloudflare.

lwthiker commented 2 years ago

Unfortunately it seems that curl doesn't implement websockets yet even though it's a highly requested feature: See here https://github.com/curl/curl/wiki/WebSockets

You can send the initial HTTP request with the 'Upgrade: websocket' header using curl but if you want to receive or send messages I think you are out of luck.

To make this work it should probably be a separate project, possibly modifying Node or another Websocket implementation to behave like curl-impersonate when opening TLS connections.

zer0def commented 1 year ago

Don't mean to jump the gun too hard (it's been only ~two weeks since it was released), but I've noticed that curl 7.86.0 has shipped with experimental websocket support, so just wanted to check whether it's something on your radar?

lwthiker commented 1 year ago

I was aware of the work being done but wasn't aware that it already landed in a release. These are good news! I would definitely attempt to upgrade to 7.86. It would be interesting to see if the impersonation works for websockets easily.

OEvans117 commented 1 year ago

Interested if you guys are thinking about implementing this :)

lwthiker commented 1 year ago

Now that curl has websocket support, I'm attempting to implement it as part of #160