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.h b/common/mock_http_fetcher.h
index 90d34dd..e56318e 100644
--- a/common/mock_http_fetcher.h
+++ b/common/mock_http_fetcher.h
@@ -17,6 +17,7 @@
#ifndef UPDATE_ENGINE_COMMON_MOCK_HTTP_FETCHER_H_
#define UPDATE_ENGINE_COMMON_MOCK_HTTP_FETCHER_H_
+#include <map>
#include <string>
#include <vector>
@@ -87,6 +88,9 @@
// The transfer cannot be resumed.
void TerminateTransfer() override;
+ void SetHeader(const std::string& header_name,
+ const std::string& header_value) override;
+
// Suspend the mock transfer.
void Pause() override;
@@ -125,6 +129,9 @@
// The number of bytes we've sent so far
size_t sent_size_;
+ // The extra headers set.
+ std::map<std::string, std::string> extra_headers_;
+
// The TaskId of the timeout callback. After each chunk of data sent, we
// time out for 0s just to make sure that run loop services other clients.
brillo::MessageLoop::TaskId timeout_id_;