mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
feat(unstable): support Deno.HttpClient
in WebSocket
(#30692)
Some checks are pending
ci / build libs (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
Some checks are pending
ci / build libs (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
This commit adds support for specifying a `Deno.HttpClient` in the `client` field of the `WebSocketOptions` bag. This mirrors how users pass a custom HTTP client to `fetch`. Additionally the underlying connection for websockets are now established through the same mechanism used for `fetch`, which means that `WebSocket` now correctly uses HTTP proxies, like when configuring the `HTTP_PROXY` env var. --------- Signed-off-by: Luca Casonato <hello@lcas.dev>
This commit is contained in:
parent
8244cd8e21
commit
97ae158610
11 changed files with 464 additions and 224 deletions
18
cli/tsc/dts/lib.deno_websocket.d.ts
vendored
18
cli/tsc/dts/lib.deno_websocket.d.ts
vendored
|
@ -307,6 +307,24 @@ interface WebSocketOptions {
|
|||
* This feature is non-standard.
|
||||
*/
|
||||
headers?: HeadersInit;
|
||||
/**
|
||||
* An `HttpClient` instance to use when creating the WebSocket connection.
|
||||
* This is useful when you need to connect through a proxy or customize TLS settings.
|
||||
*
|
||||
* ```ts
|
||||
* const client = Deno.createHttpClient({
|
||||
* proxy: {
|
||||
* transport: "unix",
|
||||
* path: "/path/to/socket",
|
||||
* },
|
||||
* });
|
||||
*
|
||||
* const ws = new WebSocket("ws://localhost:8000/socket", { client });
|
||||
* ```
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
client?: Deno.HttpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue