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.
(cherry picked from commit fdd6dec9c4be2fbd667cf874c4cc6f4ffecaeef9)
Change-Id: I59d38d79a7b7a8975d105c611c692522b6c33707
diff --git a/common/http_fetcher.h b/common/http_fetcher.h
index 11e8e9f..d2499eb 100644
--- a/common/http_fetcher.h
+++ b/common/http_fetcher.h
@@ -44,7 +44,7 @@
// |proxy_resolver| is the resolver that will be consulted for proxy
// settings. It may be null, in which case direct connections will
// be used. Does not take ownership of the resolver.
- HttpFetcher(ProxyResolver* proxy_resolver)
+ explicit HttpFetcher(ProxyResolver* proxy_resolver)
: post_data_set_(false),
http_response_code_(0),
delegate_(nullptr),
@@ -95,6 +95,12 @@
// TransferTerminated() will be called when the transfer is actually done.
virtual void TerminateTransfer() = 0;
+ // Add or update a custom header to be sent with every request. If the same
+ // |header_name| is passed twice, the second |header_value| would override the
+ // previous value.
+ virtual void SetHeader(const std::string& header_name,
+ const std::string& header_value) = 0;
+
// If data is coming in too quickly, you can call Pause() to pause the
// transfer. The delegate will not have ReceivedBytes() called while
// an HttpFetcher is paused.