mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-12 14:00:01 -04:00
return the correct headers object
This commit is contained in:
parent
563a2b7310
commit
0b14c32b25
4 changed files with 16 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue