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/update_attempter_android.cc b/update_attempter_android.cc
index cc478a4..8403dec 100644
--- a/update_attempter_android.cc
+++ b/update_attempter_android.cc
@@ -171,6 +171,13 @@
 
   BuildUpdateActions();
   SetupDownload();
+  // Setup extra headers.
+  HttpFetcher* fetcher = download_action_->http_fetcher();
+  if (!headers[kPayloadPropertyAuthorization].empty())
+    fetcher->SetHeader("Authorization", headers[kPayloadPropertyAuthorization]);
+  if (!headers[kPayloadPropertyUserAgent].empty())
+    fetcher->SetHeader("User-Agent", headers[kPayloadPropertyUserAgent]);
+
   cpu_limiter_.StartLimiter();
   SetStatusAndNotify(UpdateStatus::UPDATE_AVAILABLE);