vi / websocat

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

-H option cannot override the Host field #82

Open halfcrazy opened 4 years ago

halfcrazy commented 4 years ago

For example ./websocat ws://192.168.16.93:7789 -H 'Host: testnginx.com' The header Host field is always 192.168.16.93:7789 not testnginx.com image

I have to write /etc/hosts to archive this. image

vi commented 4 years ago

Currently may be possible only with "Websocat 2"-style pieces (which are not yet assembled into a system and are not default for handing ws://):

target/debug/websocat -t - \
    ws-ll-c:http-request:tcp:192.168.16.93:7789  \
    --request-header 'Host: testnginx.com' \
    --request-header 'Upgrade: websocket' \
    --request-header 'Sec-WebSocket-Key: mYUkMl6bemnLatx/g7ySfw==' \
    --request-header 'Sec-WebSocket-Version: 13' \
    --request-header 'Connection: Upgrade' \
    --request-uri=/
Dulanjala007 commented 7 months ago

you could use websocat --ws-c-uri=ws://echo.websocket.org/ - ws-c:tcp:127.0.0.1:8888

Connection received on 127.0.0.1 37972
GET / HTTP/1.1
Host: echo.websocket.org
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: a04beHFEo1lslZnLwXJhSA==