mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
feat(unstable): WebSocket headers field (#30321)
This changes the second argument in the WebSocket constructor to be able to take an object, which can contain a headers field with which the headers for the connection can be set. --------- Co-authored-by: Luca Casonato <hello@lcas.dev>
This commit is contained in:
parent
b88c621f22
commit
c217928649
5 changed files with 148 additions and 23 deletions
|
@ -6,8 +6,6 @@ import { primordials } from "ext:core/mod.js";
|
|||
import { op_utf8_to_byte_string } from "ext:core/ops";
|
||||
const {
|
||||
ArrayPrototypeFind,
|
||||
ArrayPrototypeSlice,
|
||||
ArrayPrototypeSplice,
|
||||
Number,
|
||||
NumberIsFinite,
|
||||
NumberIsNaN,
|
||||
|
@ -200,16 +198,7 @@ class EventSource extends EventTarget {
|
|||
);
|
||||
|
||||
if (this.#headers) {
|
||||
const headerList = headerListFromHeaders(initialHeaders);
|
||||
const headers = this.#headers ?? ArrayPrototypeSlice(
|
||||
headerList,
|
||||
0,
|
||||
headerList.length,
|
||||
);
|
||||
if (headerList.length !== 0) {
|
||||
ArrayPrototypeSplice(headerList, 0, headerList.length);
|
||||
}
|
||||
fillHeaders(initialHeaders, headers);
|
||||
fillHeaders(initialHeaders, this.#headers);
|
||||
}
|
||||
|
||||
const req = newInnerRequest(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue