Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How I can use this repo to detect websocket http request headers? #13

Open
zydjohnHotmail opened this issue Aug 17, 2021 · 2 comments
Open

Comments

@zydjohnHotmail
Copy link

Hello:
I need some code sample on how to detect WebSocket (wss) requests.
Basically, I can visit this URL with Chrome: https://www.websocket.org/echo.html
And click on “Connect” button to connect with the WebSocket server: wss://echo.websocket.org
Then type something in the message box, or using the default text in the message box “Rock it with HTML5 WebSocket”, then click on “Send” button, then I can see the messages on the “log” textbox, like this:
CONNECTED
SENT: Rock it with HTML5 WebSocket
RECEIVED: Rock it with HTML5 WebSocket
Then open Developer Tools from Chrome, on “Network” tab, I can see there is only one WS (WebSocket) request with the following headers:
Request URL:
wss://echo.websocket.org/?encoding=text

  1. Request Method:
    GET
  2. Status Code:
    101 Web Socket Protocol Handshake
    I can use Chrome developer tools to convert the WebSocket request to Node.JS fetch:
    fetch("wss://echo.websocket.org/?encoding=text", {
    "headers": {
    "accept-language": "en-US,en;q=0.9,fr;q=0.8,nl;q=0.7,zh-CN;q=0.6,zh;q=0.5,zh-TW;q=0.4",
    "cache-control": "no-cache",
    "pragma": "no-cache",
    "sec-websocket-extensions": "permessage-deflate; client_max_window_bits",
    "sec-websocket-key": "PVg+yYO5Q3EVgtPLLV2QXQ==",
    "sec-websocket-version": "13"
    },
    "body": null,
    "method": "GET",
    "mode": "cors"
    });
    Let me know how I can use this repo to get all the headers, actually, there is only one header I need to get is: "sec-websocket-key": "PVg+yYO5Q3EVgtPLLV2QXQ=="

In my real-world job, I have to detect webscoket request from one specific web site. Using Chrome devtools, I can see that the web page uses rather complicated JavaScript to generate a websocket request, and sends it to the server. I want to write some kind of browser extension to detect the websocket request headers, actually, I only need this header: "sec-websocket-key".
Please advise,
Thanks,

@jcoglan
Copy link
Collaborator

jcoglan commented Aug 17, 2021

@zydjohnHotmail I don't believe this repo can be used for the purpose you describe.

@emmygee1
Copy link

#10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants