mirror of
https://github.com/denoland/deno.git
synced 2024-10-29 08:58:01 -04:00
fix(fetch): make prototype properties writable (#10769)
This commit is contained in:
parent
8a19f28a00
commit
379d40955a
5 changed files with 85 additions and 23 deletions
|
@ -1139,3 +1139,13 @@ unitTest(
|
||||||
assertEquals(actual, expected);
|
assertEquals(actual, expected);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
unitTest({}, function fetchWritableRespProps(): void {
|
||||||
|
const original = new Response("https://deno.land", {
|
||||||
|
status: 404,
|
||||||
|
headers: { "x-deno": "foo" },
|
||||||
|
});
|
||||||
|
const new_ = new Response("https://deno.land", original);
|
||||||
|
assertEquals(original.status, new_.status);
|
||||||
|
assertEquals(new_.headers.get("x-deno"), "foo");
|
||||||
|
});
|
||||||
|
|
|
@ -147,6 +147,8 @@
|
||||||
return this[bodySymbol].stream;
|
return this[bodySymbol].stream;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
},
|
},
|
||||||
bodyUsed: {
|
bodyUsed: {
|
||||||
/**
|
/**
|
||||||
|
@ -159,6 +161,8 @@
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
},
|
},
|
||||||
arrayBuffer: {
|
arrayBuffer: {
|
||||||
/** @returns {Promise<ArrayBuffer>} */
|
/** @returns {Promise<ArrayBuffer>} */
|
||||||
|
@ -167,6 +171,9 @@
|
||||||
const body = await consumeBody(this);
|
const body = await consumeBody(this);
|
||||||
return packageData(body, "ArrayBuffer");
|
return packageData(body, "ArrayBuffer");
|
||||||
},
|
},
|
||||||
|
writable: true,
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
},
|
},
|
||||||
blob: {
|
blob: {
|
||||||
/** @returns {Promise<Blob>} */
|
/** @returns {Promise<Blob>} */
|
||||||
|
@ -175,6 +182,9 @@
|
||||||
const body = await consumeBody(this);
|
const body = await consumeBody(this);
|
||||||
return packageData(body, "Blob", this[mimeTypeSymbol]);
|
return packageData(body, "Blob", this[mimeTypeSymbol]);
|
||||||
},
|
},
|
||||||
|
writable: true,
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
},
|
},
|
||||||
formData: {
|
formData: {
|
||||||
/** @returns {Promise<FormData>} */
|
/** @returns {Promise<FormData>} */
|
||||||
|
@ -183,6 +193,9 @@
|
||||||
const body = await consumeBody(this);
|
const body = await consumeBody(this);
|
||||||
return packageData(body, "FormData", this[mimeTypeSymbol]);
|
return packageData(body, "FormData", this[mimeTypeSymbol]);
|
||||||
},
|
},
|
||||||
|
writable: true,
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
},
|
},
|
||||||
json: {
|
json: {
|
||||||
/** @returns {Promise<any>} */
|
/** @returns {Promise<any>} */
|
||||||
|
@ -191,6 +204,9 @@
|
||||||
const body = await consumeBody(this);
|
const body = await consumeBody(this);
|
||||||
return packageData(body, "JSON");
|
return packageData(body, "JSON");
|
||||||
},
|
},
|
||||||
|
writable: true,
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
},
|
},
|
||||||
text: {
|
text: {
|
||||||
/** @returns {Promise<string>} */
|
/** @returns {Promise<string>} */
|
||||||
|
@ -199,6 +215,9 @@
|
||||||
const body = await consumeBody(this);
|
const body = await consumeBody(this);
|
||||||
return packageData(body, "text");
|
return packageData(body, "text");
|
||||||
},
|
},
|
||||||
|
writable: true,
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
return Object.defineProperties(prototype.prototype, mixin);
|
return Object.defineProperties(prototype.prototype, mixin);
|
||||||
|
|
|
@ -403,6 +403,28 @@
|
||||||
|
|
||||||
mixinBody(Request, _body, _mimeType);
|
mixinBody(Request, _body, _mimeType);
|
||||||
|
|
||||||
|
Object.defineProperty(Request.prototype, "method", {
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
Object.defineProperty(Request.prototype, "url", {
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
Object.defineProperty(Request.prototype, "headers", {
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
Object.defineProperty(Request.prototype, "redirect", {
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
Object.defineProperty(Request.prototype, "clone", {
|
||||||
|
enumerable: true,
|
||||||
|
writable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
|
||||||
webidl.converters["Request"] = webidl.createInterfaceConverter(
|
webidl.converters["Request"] = webidl.createInterfaceConverter(
|
||||||
"Request",
|
"Request",
|
||||||
Request,
|
Request,
|
||||||
|
|
|
@ -365,6 +365,40 @@
|
||||||
|
|
||||||
mixinBody(Response, _body, _mimeType);
|
mixinBody(Response, _body, _mimeType);
|
||||||
|
|
||||||
|
Object.defineProperty(Response.prototype, "type", {
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
Object.defineProperty(Response.prototype, "url", {
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
Object.defineProperty(Response.prototype, "redirected", {
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
Object.defineProperty(Response.prototype, "status", {
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
Object.defineProperty(Response.prototype, "ok", {
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
Object.defineProperty(Response.prototype, "statusText", {
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
Object.defineProperty(Response.prototype, "headers", {
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
Object.defineProperty(Response.prototype, "clone", {
|
||||||
|
enumerable: true,
|
||||||
|
writable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
|
||||||
webidl.converters["Response"] = webidl.createInterfaceConverter(
|
webidl.converters["Response"] = webidl.createInterfaceConverter(
|
||||||
"Response",
|
"Response",
|
||||||
Response,
|
Response,
|
||||||
|
|
|
@ -929,46 +929,23 @@
|
||||||
"Headers interface: operation has(ByteString)",
|
"Headers interface: operation has(ByteString)",
|
||||||
"Headers interface: operation set(ByteString, ByteString)",
|
"Headers interface: operation set(ByteString, ByteString)",
|
||||||
"Headers interface: iterable<ByteString, ByteString>",
|
"Headers interface: iterable<ByteString, ByteString>",
|
||||||
"Request interface: attribute method",
|
|
||||||
"Request interface: attribute url",
|
|
||||||
"Request interface: attribute headers",
|
|
||||||
"Request interface: attribute destination",
|
"Request interface: attribute destination",
|
||||||
"Request interface: attribute referrer",
|
"Request interface: attribute referrer",
|
||||||
"Request interface: attribute referrerPolicy",
|
"Request interface: attribute referrerPolicy",
|
||||||
"Request interface: attribute mode",
|
"Request interface: attribute mode",
|
||||||
"Request interface: attribute credentials",
|
"Request interface: attribute credentials",
|
||||||
"Request interface: attribute cache",
|
"Request interface: attribute cache",
|
||||||
"Request interface: attribute redirect",
|
|
||||||
"Request interface: attribute integrity",
|
"Request interface: attribute integrity",
|
||||||
"Request interface: attribute keepalive",
|
"Request interface: attribute keepalive",
|
||||||
"Request interface: attribute isReloadNavigation",
|
"Request interface: attribute isReloadNavigation",
|
||||||
"Request interface: attribute isHistoryNavigation",
|
"Request interface: attribute isHistoryNavigation",
|
||||||
"Request interface: attribute signal",
|
"Request interface: attribute signal",
|
||||||
"Request interface: operation clone()",
|
|
||||||
"Request interface: attribute body",
|
"Request interface: attribute body",
|
||||||
"Request interface: attribute bodyUsed",
|
"Request interface: attribute bodyUsed",
|
||||||
"Request interface: operation arrayBuffer()",
|
|
||||||
"Request interface: operation blob()",
|
|
||||||
"Request interface: operation formData()",
|
|
||||||
"Request interface: operation json()",
|
|
||||||
"Request interface: operation text()",
|
|
||||||
"Response interface: operation error()",
|
"Response interface: operation error()",
|
||||||
"Response interface: operation redirect(USVString, optional unsigned short)",
|
"Response interface: operation redirect(USVString, optional unsigned short)",
|
||||||
"Response interface: attribute type",
|
|
||||||
"Response interface: attribute url",
|
|
||||||
"Response interface: attribute redirected",
|
|
||||||
"Response interface: attribute status",
|
|
||||||
"Response interface: attribute ok",
|
|
||||||
"Response interface: attribute statusText",
|
|
||||||
"Response interface: attribute headers",
|
|
||||||
"Response interface: operation clone()",
|
|
||||||
"Response interface: attribute body",
|
"Response interface: attribute body",
|
||||||
"Response interface: attribute bodyUsed",
|
"Response interface: attribute bodyUsed",
|
||||||
"Response interface: operation arrayBuffer()",
|
|
||||||
"Response interface: operation blob()",
|
|
||||||
"Response interface: operation formData()",
|
|
||||||
"Response interface: operation json()",
|
|
||||||
"Response interface: operation text()",
|
|
||||||
"Window interface: operation fetch(RequestInfo, optional RequestInit)"
|
"Window interface: operation fetch(RequestInfo, optional RequestInit)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue