Fetcher tries all proxies when a secondary chunk download error occurs.

This is a fix to issue 18143:

* New test cases for asserting the desired behavior: if a transfer of
  a secondary chunk within a multi-chunk fetch fails, then the fetcher
  needs to retry with other available proxies; it will only fail when no
  additional proxies are available.  The tests ensure both success (one
  of the proxies eventually succeeds) and failure (all proxies fail)
  cases.

* Small fix to LibcurlHttpFetcher to retry with other proxies upon
  failure (error value) of a secondary chunk.

Other changes applied in the course of this fix:

* Massive refactoring of http_fetcher_unittest: substituted template
  specialization in typed test setup with proper subclassing, resulting
  in a safer and more maintainable infrastructure;  extended URLs to
  include all (most) parameters pertaining to test workload, such as
  download size, flakiness, etc.

* Respective changes to test_http_server: it is now much more
  independent of particular kind of tests, and more easily
  parametrizable.  Also, generalized several internal methods for better
  readability and extensibility, such as writing of arbitrary payloads,
  parsing headers,

* Migrated common definitions into http_common.{h,cc} (universal
  HTTP-related stuff) and http_fetcher_unittest.h (shared definitions
  pertaining to unit tests).

* Extended direct proxy resolver to generate a list of (non-) proxies,
  so we can unit test proxy failure.  Also, better logging to improve
  testability.

* Some renaming of classes for better consistency.

BUG=chromium-os:18143
TEST=unit tests

Change-Id: Ib90b53394d7e47184d9953df8fc80348921e8af0
Reviewed-on: https://gerrit.chromium.org/gerrit/12092
Commit-Ready: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
diff --git a/multi_range_http_fetcher.h b/multi_range_http_fetcher.h
index 306ac2a..342588a 100644
--- a/multi_range_http_fetcher.h
+++ b/multi_range_http_fetcher.h
@@ -14,14 +14,14 @@
 #include "update_engine/http_fetcher.h"
 
 // This class is a simple wrapper around an HttpFetcher. The client
-// specifies a vector of byte ranges. MultiRangeHTTPFetcher will fetch bytes
+// specifies a vector of byte ranges. MultiRangeHttpFetcher will fetch bytes
 // from those offsets, using the same bash fetcher for all ranges. Thus, the
 // fetcher must support beginning a transfter after one has stopped. Pass -1
 // as a length to specify unlimited length. It really only would make sense
 // for the last range specified to have unlimited length, tho it is legal for
 // other entries to have unlimited length.
 
-// There are three states a MultiRangeHTTPFetcher object will be in:
+// There are three states a MultiRangeHttpFetcher object will be in:
 // - Stopped (start state)
 // - Downloading
 // - Pending transfer ended
@@ -30,10 +30,10 @@
 
 namespace chromeos_update_engine {
 
-class MultiRangeHTTPFetcher : public HttpFetcher, public HttpFetcherDelegate {
+class MultiRangeHttpFetcher : public HttpFetcher, public HttpFetcherDelegate {
  public:
   // Takes ownership of the passed in fetcher.
-  explicit MultiRangeHTTPFetcher(HttpFetcher* base_fetcher)
+  explicit MultiRangeHttpFetcher(HttpFetcher* base_fetcher)
       : HttpFetcher(base_fetcher->proxy_resolver()),
         base_fetcher_(base_fetcher),
         base_fetcher_active_(false),
@@ -41,7 +41,7 @@
         terminating_(false),
         current_index_(0),
         bytes_received_this_range_(0) {}
-  ~MultiRangeHTTPFetcher() {}
+  ~MultiRangeHttpFetcher() {}
 
   void ClearRanges() { ranges_.clear(); }
 
@@ -122,7 +122,7 @@
   RangesVect::size_type current_index_;  // index into ranges_
   off_t bytes_received_this_range_;
 
-  DISALLOW_COPY_AND_ASSIGN(MultiRangeHTTPFetcher);
+  DISALLOW_COPY_AND_ASSIGN(MultiRangeHttpFetcher);
 };
 
 }  // namespace chromeos_update_engine