Skip to content

Commit

Permalink
Headless: don't override user agent from headless embedder, we are wa…
Browse files Browse the repository at this point in the history
…lking away from that.

Change-Id: I1411429de9f3bb92eae22c6911a4caeb4a2932f7
TBR: eseckler
Reviewed-on: https://chromium-review.googlesource.com/1071874
Commit-Queue: Pavel Feldman <pfeldman@chromium.org>
Reviewed-by: Eric Seckler <eseckler@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561557}
  • Loading branch information
pavelfeldman authored and Commit Bot committed May 24, 2018
1 parent 89d0b86 commit 2a3175d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
7 changes: 1 addition & 6 deletions headless/public/util/generic_url_request_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,11 @@ void GenericURLRequestJob::SetExtraRequestHeaders(

const net::HttpUserAgentSettings* user_agent_settings =
request()->context()->http_user_agent_settings();
// If set the |user_agent_settings| accept language is a fallback.
if (user_agent_settings) {
// If set the |user_agent_settings| accept language is a fallback.
extra_request_headers_.SetHeaderIfMissing(
net::HttpRequestHeaders::kAcceptLanguage,
user_agent_settings->GetAcceptLanguage());
// If set the |user_agent_settings| user agent is an override.
if (!user_agent_settings->GetUserAgent().empty()) {
extra_request_headers_.SetHeader(net::HttpRequestHeaders::kUserAgent,
user_agent_settings->GetUserAgent());
}
}
}

Expand Down
7 changes: 1 addition & 6 deletions headless/public/util/generic_url_request_job_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "net/base/upload_bytes_element_reader.h"
#include "net/http/http_response_headers.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/static_http_user_agent_settings.h"
#include "net/url_request/url_request_job_factory_impl.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand Down Expand Up @@ -252,7 +251,6 @@ class GenericURLRequestJobTest : public testing::Test {
};

TEST_F(GenericURLRequestJobTest, BasicGetRequestParams) {
net::StaticHttpUserAgentSettings user_agent_settings("en-UK", "TestBrowser");

json_fetch_reply_map_["https://example.com/"] = R"(
{
Expand All @@ -263,7 +261,6 @@ TEST_F(GenericURLRequestJobTest, BasicGetRequestParams) {
}
})";

url_request_context_.set_http_user_agent_settings(&user_agent_settings);
std::unique_ptr<net::URLRequest> request(url_request_context_.CreateRequest(
GURL("https://example.com"), net::DEFAULT_PRIORITY, &request_delegate_,
TRAFFIC_ANNOTATION_FOR_TESTS));
Expand All @@ -277,10 +274,8 @@ TEST_F(GenericURLRequestJobTest, BasicGetRequestParams) {
"url": "https://example.com/",
"method": "GET",
"headers": {
"Accept-Language": "en-UK",
"Extra-Header": "Value",
"Referer": "https://referrer.example.com/",
"User-Agent": "TestBrowser"
"Referer": "https://referrer.example.com/"
}
})";

Expand Down

0 comments on commit 2a3175d

Please sign in to comment.