-
Notifications
You must be signed in to change notification settings - Fork 540
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial handshake * minor fixes * feat: working initial handshake! * feat(ws): initial WebSocket class implementation * fix: allow http: and ws: urls * fix(ws): use websocket spec * fix(ws): use websocket spec * feat: implement url getter * feat: implement some of `WebSocket.close` and ready state * fix: body is null for websockets & pass socket to response * fix: store the fetch controller & response on ws * fix: remove invalid tests * feat: implement readyState getter * feat: implement `protocol` and `extensions` getters * feat: implement event listeners * feat: implement binaryType attribute * fix: add argument length checks * feat: basic unfragmented message parsing * fix: always remove previous listener * feat: add in idlharness WPT * implement sending a message for WS and add a websocketFrame class * feat: allow sending ArrayBuffer/Views & Blob * fix: remove duplicate `upgrade` and `connection` headers * feat: add in WebSocket.close() and handle closing frames * refactor WebsocketFrame and support receiving frames in multiple chunks * fixes * move WebsocketFrame to its own file * feat: export WebSocket & add types * fix: tsd * feat(wpt): use WebSocketServer & run test * fix: properly set/read close code & close reason * fix: flakiness in websocket test runner * fix: receive message with arraybuffer binary type * feat: split WebsocketFrame into 2 classes (sent & received) * fix: parse fragmented frames more efficiently & close frame * fix: add types for MessageEvent and CloseEvent * fix: subprotocol validation & add wpts * fix: protocol validation & protocol webidl & add wpts * fix: correct bufferedAmount calc. & message event w/ blob * fix: don't truncate typedarrays * feat: add remaining wpts * fix: allow sending payloads > 65k bytes * fix: mask data > 125 bytes properly * revert changes to core * fix: decrement bufferedAmount after write * fix: handle ping and pong frames * fix: simplify receiving frame logic * fix: disable extensions & validate frames * fix: send close frame upon receiving * lint * fix: validate status code & utf-8 * fix: add hooks * fix: check if frame is unfragmented correctly * fix: send ping app data in pong frames * export websocket on node >= 18 & add diagnostic_channels * mark test as flaky * fix: couple bug fixes * fix: fragmented frame end detection * fix: use TextDecoder for utf-8 validation * fix: handle incomplete chunks * revert: handle incomplete chunks * mark WebSockets as experimental * fix: sending 65k bytes is still flaky on linux * fix: apply suggestions * fix: apply some suggestions * add basic docs * feat: use streaming parser for frames * feat: validate some frames & remove WebsocketFrame class * fix: parse close frame & move failWebsocketConnection * fix: read close reason and read entire close body * fix: echo close frame if one hasn't been sent * fix: emit message event on message receive * fix: minor fixes * fix: ci * fix: set was clean exit after server receives close frame * fix: check if received close frame for clean close * fix: set sent close after writing frame * feat: implement error messages * fix: add error event handler to socket * fix: address reviews Co-authored-by: Subhi Al Hasan <[email protected]>
- Loading branch information
Showing
92 changed files
with
3,881 additions
and
15 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Class: WebSocket | ||
|
||
> ⚠️ Warning: the WebSocket API is experimental and has known bugs. | ||
Extends: [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) | ||
|
||
The WebSocket object provides a way to manage a WebSocket connection to a server, allowing bidirectional communication. The API follows the [WebSocket spec](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket). | ||
|
||
## `new WebSocket(url[, protocol])` | ||
|
||
Arguments: | ||
|
||
* **url** `URL | string` - The url's protocol *must* be `ws` or `wss`. | ||
* **protocol** `string | string[]` (optional) - Subprotocol(s) to request the server use. | ||
|
||
## Read More | ||
|
||
- [MDN - WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) | ||
- [The WebSocket Specification](https://www.rfc-editor.org/rfc/rfc6455) | ||
- [The WHATWG WebSocket Specification](https://websockets.spec.whatwg.org/) |
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
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
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
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
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
Oops, something went wrong.