Set X-GoogleUpdate headers on Omaha requests.
When sending requests to Omaha, set the custom X-GoogleUpdate-* headers
to help identify the request type without parsing the actual request.
Bug: 28823234
TEST=Added unittests.
Change-Id: I4f0d64b4fc0f69e8a5d4b86337331a3a7a481b35
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index 82f9ae8..9291e05 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -458,6 +458,31 @@
EXPECT_FALSE(fake_prefs_.Exists(kPrefsOmahaCohortName));
}
+TEST_F(OmahaRequestActionTest, ExtraHeadersSentTest) {
+ const string http_response = "<?xml invalid response";
+ request_params_.set_interactive(true);
+
+ brillo::FakeMessageLoop loop(nullptr);
+ loop.SetAsCurrent();
+
+ MockHttpFetcher* fetcher =
+ new MockHttpFetcher(http_response.data(), http_response.size(), nullptr);
+ OmahaRequestAction action(
+ &fake_system_state_, nullptr, brillo::make_unique_ptr(fetcher), false);
+ ActionProcessor processor;
+ processor.EnqueueAction(&action);
+
+ loop.PostTask(base::Bind([&processor] { processor.StartProcessing(); }));
+ loop.Run();
+ EXPECT_FALSE(loop.PendingTasks());
+
+ // Check that the headers were set in the fetcher during the action. Note that
+ // we set this request as "interactive".
+ EXPECT_EQ("fg", fetcher->GetHeader("X-GoogleUpdate-Interactivity"));
+ EXPECT_EQ(kTestAppId, fetcher->GetHeader("X-GoogleUpdate-AppId"));
+ EXPECT_NE("", fetcher->GetHeader("X-GoogleUpdate-Updater"));
+}
+
TEST_F(OmahaRequestActionTest, ValidUpdateBlockedByConnection) {
OmahaResponse response;
// Set up a connection manager that doesn't allow a valid update over