Updater avoids download in case of an error HTTP response.

(a) LibcurlHttpFetcher avoids download if the HTTP reponse indicates an
error; corresponding change to unit test code and test HTTP server.  (b)
Added a method for returning the total bytes downloaded to HttpFetcher
and all subclasses, needed for unit testing.  (c) Generalized check for
successful HTTP response code in LibcurlHttpFetcher.

BUG=chromium-os:9648
TEST=unit tests

Change-Id: I46d72fbde0ecfb53823b0705ce17f9547515ee61
Reviewed-on: https://gerrit.chromium.org/gerrit/11773
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
Commit-Ready: Gilad Arnold <garnold@chromium.org>
diff --git a/libcurl_http_fetcher.h b/libcurl_http_fetcher.h
index b436de6..d727f19 100644
--- a/libcurl_http_fetcher.h
+++ b/libcurl_http_fetcher.h
@@ -99,6 +99,10 @@
     check_certificate_ = check_certificate;
   }
 
+  virtual size_t GetBytesDownloaded() {
+    return static_cast<size_t>(bytes_downloaded_);
+  }
+
  private:
   // Callback for when proxy resolution has completed. This begins the
   // transfer.
@@ -107,6 +111,11 @@
   // Asks libcurl for the http response code and stores it in the object.
   void GetHttpResponseCode();
 
+  // Checks whether stored HTTP response is successful.
+  inline bool IsHttpResponseSuccess() {
+    return (http_response_code_ >= 200 && http_response_code_ < 300);
+  }
+
   // Resumes a transfer where it left off. This will use the
   // HTTP Range: header to make a new connection from where the last
   // left off.