return the correct headers object

This commit is contained in:
ading2210 2024-01-18 15:00:00 -05:00
parent 563a2b7310
commit 0b14c32b25
4 changed files with 16 additions and 2 deletions

View file

@ -122,6 +122,7 @@ function create_response(response_data, response_info) {
response_info.ok = response_info.status >= 200 && response_info.status < 300;
response_info.statusText = status_messages[response_info.status] || "";
//construct base response object
let response_obj = new Response(response_data, response_info);
for (let key in response_info) {
if (key == "headers") continue;
@ -130,6 +131,13 @@ function create_response(response_data, response_info) {
value: response_info[key]
});
}
//create headers object
Object.defineProperty(response_obj, "headers", {
writable: false,
value: new Headers(response_info.headers)
});
return response_obj;
}