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/libcurl_http_fetcher.h b/common/libcurl_http_fetcher.h
index 218e6cb..d126171 100644
--- a/common/libcurl_http_fetcher.h
+++ b/common/libcurl_http_fetcher.h
@@ -57,6 +57,10 @@
   // cannot be resumed.
   void TerminateTransfer() override;
 
+  // Pass the headers to libcurl.
+  void SetHeader(const std::string& header_name,
+                 const std::string& header_value) override;
+
   // Suspend the transfer by calling curl_easy_pause(CURLPAUSE_ALL).
   void Pause() override;
 
@@ -181,6 +185,9 @@
   CURL* curl_handle_{nullptr};
   struct curl_slist* curl_http_headers_{nullptr};
 
+  // The extra headers that will be sent on each request.
+  std::map<std::string, std::string> extra_headers_;
+
   // Lists of all read(0)/write(1) file descriptors that we're waiting on from
   // the message loop. libcurl may open/close descriptors and switch their
   // directions so maintain two separate lists so that watch conditions can be