mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 08:09:08 -05:00
parent
25b35be50d
commit
644a7ff2d7
5 changed files with 32 additions and 9 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -501,7 +501,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deno_fetch"
|
name = "deno_fetch"
|
||||||
version = "0.20.1"
|
version = "0.20.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"deno_core",
|
"deno_core",
|
||||||
|
|
|
@ -25,7 +25,7 @@ path = "./bench/main.rs"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
deno_core = { path = "../core", version = "0.77.1" }
|
deno_core = { path = "../core", version = "0.77.1" }
|
||||||
deno_fetch = { path = "../op_crates/fetch", version = "0.20.1" }
|
deno_fetch = { path = "../op_crates/fetch", version = "0.20.2" }
|
||||||
deno_web = { path = "../op_crates/web", version = "0.28.1" }
|
deno_web = { path = "../op_crates/web", version = "0.28.1" }
|
||||||
deno_websocket = { path = "../op_crates/websocket", version = "0.3.1" }
|
deno_websocket = { path = "../op_crates/websocket", version = "0.3.1" }
|
||||||
regex = "1.4.3"
|
regex = "1.4.3"
|
||||||
|
|
|
@ -682,6 +682,10 @@
|
||||||
|
|
||||||
const teeBody = Symbol("Body#tee");
|
const teeBody = Symbol("Body#tee");
|
||||||
|
|
||||||
|
// fastBody and dontValidateUrl allow users to opt out of certain behaviors
|
||||||
|
const fastBody = Symbol("Body#fast");
|
||||||
|
const dontValidateUrl = Symbol("dontValidateUrl");
|
||||||
|
|
||||||
class Body {
|
class Body {
|
||||||
#contentType = "";
|
#contentType = "";
|
||||||
#size;
|
#size;
|
||||||
|
@ -730,6 +734,17 @@
|
||||||
return this.#stream;
|
return this.#stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Optimization that allows caller to bypass expensive ReadableStream.
|
||||||
|
[fastBody]() {
|
||||||
|
if (!this.#bodySource) {
|
||||||
|
return null;
|
||||||
|
} else if (!(this.#bodySource instanceof ReadableStream)) {
|
||||||
|
return bodyToArrayBuffer(this.#bodySource);
|
||||||
|
} else {
|
||||||
|
return this.body;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** @returns {BodyInit | null} */
|
/** @returns {BodyInit | null} */
|
||||||
[teeBody]() {
|
[teeBody]() {
|
||||||
if (this.#stream || this.#bodySource instanceof ReadableStream) {
|
if (this.#stream || this.#bodySource instanceof ReadableStream) {
|
||||||
|
@ -991,10 +1006,16 @@
|
||||||
this.#headers = new Headers(input.headers);
|
this.#headers = new Headers(input.headers);
|
||||||
this.#credentials = input.credentials;
|
this.#credentials = input.credentials;
|
||||||
} else {
|
} else {
|
||||||
const baseUrl = getLocationHref();
|
// Constructing a URL just for validation is known to be expensive.
|
||||||
this.#url = baseUrl != null
|
// dontValidateUrl allows one to opt out.
|
||||||
? new URL(String(input), baseUrl).href
|
if (init[dontValidateUrl]) {
|
||||||
: new URL(String(input)).href;
|
this.#url = input;
|
||||||
|
} else {
|
||||||
|
const baseUrl = getLocationHref();
|
||||||
|
this.#url = baseUrl != null
|
||||||
|
? new URL(String(input), baseUrl).href
|
||||||
|
: new URL(String(input)).href;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (init && "method" in init && init.method) {
|
if (init && "method" in init && init.method) {
|
||||||
|
@ -1477,5 +1498,7 @@
|
||||||
Response,
|
Response,
|
||||||
HttpClient,
|
HttpClient,
|
||||||
createHttpClient,
|
createHttpClient,
|
||||||
|
fastBody,
|
||||||
|
dontValidateUrl,
|
||||||
};
|
};
|
||||||
})(this);
|
})(this);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "deno_fetch"
|
name = "deno_fetch"
|
||||||
version = "0.20.1"
|
version = "0.20.2"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "provides fetch Web API to deno_core"
|
description = "provides fetch Web API to deno_core"
|
||||||
authors = ["the Deno authors"]
|
authors = ["the Deno authors"]
|
||||||
|
|
|
@ -20,7 +20,7 @@ path = "examples/hello_runtime.rs"
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
deno_core = { path = "../core", version = "0.77.1" }
|
deno_core = { path = "../core", version = "0.77.1" }
|
||||||
deno_crypto = { path = "../op_crates/crypto", version = "0.11.1" }
|
deno_crypto = { path = "../op_crates/crypto", version = "0.11.1" }
|
||||||
deno_fetch = { path = "../op_crates/fetch", version = "0.20.1" }
|
deno_fetch = { path = "../op_crates/fetch", version = "0.20.2" }
|
||||||
deno_web = { path = "../op_crates/web", version = "0.28.1" }
|
deno_web = { path = "../op_crates/web", version = "0.28.1" }
|
||||||
deno_websocket = { path = "../op_crates/websocket", version = "0.3.1" }
|
deno_websocket = { path = "../op_crates/websocket", version = "0.3.1" }
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ winapi = "0.3.9"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
deno_core = { path = "../core", version = "0.77.1" }
|
deno_core = { path = "../core", version = "0.77.1" }
|
||||||
deno_crypto = { path = "../op_crates/crypto", version = "0.11.1" }
|
deno_crypto = { path = "../op_crates/crypto", version = "0.11.1" }
|
||||||
deno_fetch = { path = "../op_crates/fetch", version = "0.20.1" }
|
deno_fetch = { path = "../op_crates/fetch", version = "0.20.2" }
|
||||||
deno_web = { path = "../op_crates/web", version = "0.28.1" }
|
deno_web = { path = "../op_crates/web", version = "0.28.1" }
|
||||||
deno_websocket = { path = "../op_crates/websocket", version = "0.3.1" }
|
deno_websocket = { path = "../op_crates/websocket", version = "0.3.1" }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue