Skip to content

[webRequest.onHeadersReceived] Not all requests show modified headers #45168

@t57ser

Description

@t57ser

Preflight Checklist

Electron Version

34.0.0

What operating system(s) are you using?

Windows

Operating System Version

Windows 10

What arch are you using?

x64

Last Known Working Electron version

14.2.9

Expected Behavior

All requests that are handled with onHeadersReceived should show modified headers (if they are being modified in the handler)

Actual Behavior

Some requests do not show the modified headers.
Example:

electron.session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
		console.log(details.url, details.responseHeaders);
		if (details.responseHeaders) {
			details.responseHeaders["test"] = ["1"];
		}
		callback({cancel: false, responseHeaders: details.responseHeaders});
	});

I am setting a "test" header to each request
Navigating to google.com does not show the header in the first request:
Image
It does appear in the second request though

Testcase Gist URL

https://gist.github.com/t57ser/b97184b3c8772a8ccf7cb600ceac1202

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions