Parse and use extra HTTP headers when downloading the payload.
Android OTA backend requires to pass an Authorization HTTP header in
order to download some payload. This patch allows to specify such
header when initiating a payload download from Android.
Bug: 27047110
TEST=Added unittests to check the headers sent.
Change-Id: Iece7e0ee252349bbaa9fb8545da2c34d2a76ae69
diff --git a/common/mock_http_fetcher.cc b/common/mock_http_fetcher.cc
index f3fa70d..d0348f1 100644
--- a/common/mock_http_fetcher.cc
+++ b/common/mock_http_fetcher.cc
@@ -20,6 +20,7 @@
#include <base/bind.h>
#include <base/logging.h>
+#include <base/strings/string_util.h>
#include <base/time/time.h>
#include <gtest/gtest.h>
@@ -117,6 +118,11 @@
delegate_->TransferTerminated(this);
}
+void MockHttpFetcher::SetHeader(const std::string& header_name,
+ const std::string& header_value) {
+ extra_headers_[base::ToLowerASCII(header_name)] = header_value;
+}
+
void MockHttpFetcher::Pause() {
CHECK(!paused_);
paused_ = true;