Skip to content
This repository has been archived by the owner on Jun 20, 2020. It is now read-only.

Unable to Add Header on await tab.open(). #25

Closed
mrhodd opened this issue Mar 6, 2018 · 4 comments
Closed

Unable to Add Header on await tab.open(). #25

mrhodd opened this issue Mar 6, 2018 · 4 comments

Comments

@mrhodd
Copy link

mrhodd commented Mar 6, 2018

I'm using NickJs browser emulation and am attempting to add a header when opening a page. I'm monitoring the request in Fiddler and see that the header is not being added.

How do I add the header?

Here's my current code:

await tab.open("https://www.google.com/", {headers: {"Accept-Language": "en-US,en;q=0.9"}})

@paps
Copy link
Member

paps commented Mar 6, 2018

The header feature is not yet implemented for the Chrome backend unfortunately.

I will try to implement it soon. In the meantime, as an alternative, you can use

	await tab.driver.client.Network.setExtraHTTPHeaders({
		headers: {
			"Header key": "Header value",
		}
	})

Do this before your open() call.

This makes use of the underlying CDP (chrome-remote-interface) client which implements the Chrome DevTools Protocol (see doc for the Network namespace)

@mrhodd
Copy link
Author

mrhodd commented Mar 6, 2018

Awesome!! Thank you for the response!

This has resolved my issue!

@mrhodd
Copy link
Author

mrhodd commented Mar 6, 2018

Side note, is it possible to set the order of this header? I noticed it doesn't appear in the same order as a request from my browser does (and unfortunately I do think that header order matters here...).

@paps
Copy link
Member

paps commented Mar 6, 2018

I'm not aware of any way to control the order of headers, sorry

@paps paps closed this as completed Mar 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants