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/common/mock_http_fetcher.cc b/common/mock_http_fetcher.cc
index d0348f1..f1ae72a 100644
--- a/common/mock_http_fetcher.cc
+++ b/common/mock_http_fetcher.cc
@@ -123,6 +123,13 @@
extra_headers_[base::ToLowerASCII(header_name)] = header_value;
}
+std::string MockHttpFetcher::GetHeader(const std::string& header_name) const {
+ const auto it = extra_headers_.find(base::ToLowerASCII(header_name));
+ if (it == extra_headers_.end())
+ return "";
+ return it->second;
+}
+
void MockHttpFetcher::Pause() {
CHECK(!paused_);
paused_ = true;
diff --git a/common/mock_http_fetcher.h b/common/mock_http_fetcher.h
index e56318e..367802e 100644
--- a/common/mock_http_fetcher.h
+++ b/common/mock_http_fetcher.h
@@ -91,6 +91,10 @@
void SetHeader(const std::string& header_name,
const std::string& header_value) override;
+ // Return the value of the header |header_name| or the empty string if not
+ // set.
+ std::string GetHeader(const std::string& header_name) const;
+
// Suspend the mock transfer.
void Pause() override;