- Notifications
You must be signed in to change notification settings - Fork18
The WebSocketStream Interface#48
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
579e4133c4803b8e5f06b5cb355b1f9a2d696baeed69bae4ffa5ff83adf4bbef488ee4b1a58f48cc184c781216347ab0da2b9ee8012ff404a2fc7c23a285c7397dd009e8d8f7673ace930f5f8b7d857721d7d8687b81f796da74e716a75fe2bd7ad5b2e001c1e2eae924f24f8a6d426fd5570f3File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
Also apply backpressure on connection, and linkify "exists".
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -796,6 +796,9 @@ which is a {{WritableStream}}. | ||
| Each {{WebSocketStream}} object has an associated <dfn for="WebSocketStream">was ever connected | ||
| flag</dfn>, which is initially unset. | ||
| Each {{WebSocketStream}} object has an associated <dfn for="WebSocketStream">handshake aborted | ||
| flag</dfn>, which is initially unset. | ||
ricea marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| Each {{WebSocketStream}} object has an associated <dfn for="WebSocketStream">ready state</dfn>, | ||
| which is a number representing the state of the connection. Initially it must be | ||
| {{WebSocket/CONNECTING}} (0). It has the same semantics as {{WebSocket}}'s [=WebSocket/ready | ||
| @@ -895,15 +898,30 @@ state=], but is not exposed to JavaScript. | ||
| 1. Let |baseURL| be [=this=]'s [=relevant settings object=]'s [=API base URL=]. | ||
| 1. Let |urlRecord| be the result of [=get a URL record|getting a URL record=] given |url| and | ||
| |baseURL|. | ||
| 1. Let |protocols| be |options|["{{WebSocketStreamOptions/protocols}}"] if it[=map/exists=], | ||
| otherwise anempty sequence. | ||
| 1. If any of the values in |protocols| occur more than once or otherwise fail to match the | ||
| requirements for elements that comprise the value of | ||
| \`<a http-header>`Sec-WebSocket-Protocol`</a>\` fields as defined by The WebSocket protocol, | ||
| then throw a "{{SyntaxError}}" {{DOMException}}. [[!WSP]] | ||
| 1. Set [=this=]'s [=WebSocketStream/url=] to |urlRecord|. | ||
| 1. Set [=this=]'s [=WebSocketStream/opened promise=] and [=WebSocketStream/closed promise=] to new | ||
| promises. | ||
| 1. Apply backpressure to the WebSocket. | ||
| Note: This means that messages won't be read until the application is ready for them. | ||
| 1. If |options|["{{WebSocketStreamOptions/signal}}"] [=map/exists=], | ||
| 1. Let |signal| be |options|["{{WebSocketStreamOptions/signal}}"]. | ||
| 1. If |signal| is [=AbortSignal/aborted=], then reject [=this=]'s [=WebSocketStream/opened | ||
| promise=] and [=WebSocketStream/closed promise=] with |signal|'s [=abort reason=] and return. | ||
| 1. [=AbortSignal/add|Add the following abort steps=] to |signal|: | ||
| 1. If the WebSocket connection is not yet [=established=] [[!WSP]] | ||
ricea marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| 1. [=Fail the WebSocket connection=] and set [=this=]'s [=WebSocketStream/ready state=] to | ||
ricea marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| {{WebSocket/CLOSING}}. | ||
| 1. [=Reject=] [=this=]'s [=WebSocketStream/opened promise=] and [=WebSocketStream/closed | ||
| promise=] with |signal|'s [=abort reason=]. | ||
| 1. Set [=this=]'s [=WebSocketStream/handshake aborted flag=]. | ||
| 1. Let |client| be [=this=]'s [=relevant settings object=]. | ||
| 1. Run this step [=in parallel=]: | ||
| 1. [=Establish a WebSocket connection=] given |urlRecord|, |protocols|, and |client|. [[!FETCH]] | ||
| @@ -1008,6 +1026,7 @@ When [=the WebSocket connection is closed=] for a {{WebSocketStream}} |stream|, | ||
| [=cleanly=], the user agent must [=queue a task=] to run the following substeps: | ||
| 1. Change the [=WebSocketStream/ready state=] to {{WebSocket/CLOSED}} (3). | ||
ricea marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| 1. If |stream|'s [=WebSocketStream/handshake aborted flag=] is set, then return. | ||
| 1. If |stream|'s [=WebSocketStream/was ever connected flag=] is not set, then [=reject=] |stream|'s | ||
| [=opened promise=] with a [=new=] WebSocketError. | ||
ricea marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page.
ricea marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| 1. Let |code| be [=the WebSocket connection close code=]. | ||
| @@ -1174,8 +1193,10 @@ WebSocketError(|message|, |init|)</code></dfn> constructor steps are: | ||
| 1. Set |this|'s [=DOMException/name=] to "<code>WebSocketError</code>". | ||
| 1. Set |this|'s [=DOMException/message=] to |message|. | ||
| 1. Let |code| be |init|["{{WebSocketCloseInfo/closeCode}}"] if it [=map/exists=], or unset | ||
| otherwise. | ||
| 1. Let |reason| be |init|["{{WebSocketCloseInfo/reason}}"] if it [=map/exists=], or unset | ||
| otherwise. | ||
ricea marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| 1. [=Validate close code and reason=] with |code| and |reason|. | ||
| 1. If |reason| is non-empty, but |code| is not set, then set |code| to 1000 ("Normal Closure"). | ||
ricea marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| 1. Set |this|'s [=WebSocketError/closeCode=] to |code|. | ||