Last active
April 22, 2024 14:14
-
-
Save htp/fbce19069187ec1cc486b594104f01d0 to your computer and use it in GitHub Desktop.
Test a WebSocket using curl.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl --include \ | |
--no-buffer \ | |
--header "Connection: Upgrade" \ | |
--header "Upgrade: websocket" \ | |
--header "Host: example.com:80" \ | |
--header "Origin: http://example.com:80" \ | |
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \ | |
--header "Sec-WebSocket-Version: 13" \ | |
http://example.com:80/ |
curl --include \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Sec-WebSocket-Key: qwerty" \
http://localhost:8000/
This worked for me. I didn't need all the header items
Anyone know if you can use this to send data (i.e. from stdin or a file) through the web socket? I tried -T -
, but that doesn't seem to work.
curl --include \
-H "Connection: Upgrade" \
-H "Upgrade: websocket" \
-H "Sec-WebSocket-Key: qwerty" \
-H "Sec-WebSocket-Version: 13" \
https://example.com -k
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, it works!