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/libcurl_http_fetcher.h b/common/libcurl_http_fetcher.h
index 66dbb18..5a64236 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