Why can't I see all the expected headers from the Fetch Response?

I am using the Fetch API to create an HTTP request.

fetch(url, options)
  .then(response => 
    console.log(...response.headers.keys())); // "content-type"

But I see from Chrome that there are more headers in the incoming HTTP response (Date, Server, Transfer-Encoding, X-foo). Why can't I see them in the output for the above code?

I start Chrome with the following flags:

C:\path\chrome.exe  --disable-web-security --user-data-dir=C:\path\tmp\chrome

Answer:

body: (...)
bodyUsed: false
headers: Headers
ok: true
status: 200
statusText: "OK"
type: "cors"
url: "http://origin?query"

I note that executing a non-CORS request saves headers. Does CORS separate them?

body: (...)
bodyUsed: false
headers: Headers
ok: true
status: 200
statusText: "OK"
type: "basic"
url: "http://origin?query"
+4
source share

Source: https://habr.com/ru/post/1648373/


All Articles