From b29a8c94b927ecb16ba7c83748a692332310f836 Mon Sep 17 00:00:00 2001 From: Gohy Leandre Date: Mon, 26 Oct 2015 22:18:16 +0100 Subject: [PATCH] Add extra headers option to webContents.loadUrl --- atom/browser/api/atom_api_web_contents.cc | 4 ++++ docs/api/web-contents.md | 1 + 2 files changed, 5 insertions(+) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 5b3ef2f4aa7b..900c3e65a376 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -618,6 +618,10 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) { if (options.Get("userAgent", &user_agent)) SetUserAgent(user_agent); + std::string extra_headers; + if (options.Get("extraHeaders", &extra_headers)) + params.extra_headers = extra_headers; + params.transition_type = ui::PAGE_TRANSITION_TYPED; params.should_clear_history_list = true; params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE; diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 7633efbfb3de..3113356e34b4 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -183,6 +183,7 @@ See [session documentation](session.md) for this object's methods. * `options` Object (optional), properties: * `httpReferrer` String - A HTTP Referrer url. * `userAgent` String - A user agent originating the request. + * `extraHeaders` String - Extra headers separated by "\n" Loads the `url` in the window, the `url` must contain the protocol prefix, e.g. the `http://` or `file://`.