http-party / http-server

a simple zero-configuration command-line http server
MIT License
13.42k stars 1.48k forks source link

Proxy WebSocket connections with error handling #872

Open Hermholtz opened 7 months ago

Hermholtz commented 7 months ago

Properly proxy WebSocket "upgrade" connections. Without this change any attempt to use http-server as a proxy for WebSocket does not work. The code also handles error cases when WebSocket server abruptly closes connection (or a network device dies between client and server). Other PRs fixing the same issue cause http-server to throw error and exit on WebSocket connection errors.

It's a useful addition to http-server for people developing WebSocket applications. There's no WebSocket proxy for Node.js easy to use from command line. This pull request makes http-server more versatile and helps local dev workflows.

The change is as minimal as possible, no code style changes, no whitespace changes etc. Please merge.

Relevant issues

Fixes #142.

Contributor checklist

Note: cannot provide unit tests for this change. Note: this doesn't add any new command line options.

Maintainer checklist