Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Unified Diff: headless/public/util/url_fetcher.cc

Issue 2260793002: Headless utility classes for making deterministic protocol handlers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « headless/public/util/url_fetcher.h ('k') | headless/public/util/url_request_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/public/util/url_fetcher.cc
diff --git a/headless/public/util/url_fetcher.cc b/headless/public/util/url_fetcher.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8d8d33fc239a0a0c5026a859b96835304bea059d
--- /dev/null
+++ b/headless/public/util/url_fetcher.cc
@@ -0,0 +1,40 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "headless/public/util/url_fetcher.h"
+
+#include <utility>
+
+#include "base/logging.h"
+#include "net/http/http_response_headers.h"
+#include "net/http/http_util.h"
+
+namespace headless {
+
+void URLFetcher::ResultListener::OnFetchCompleteExtractHeaders(
+ const GURL& final_url,
+ int http_response_code,
+ const char* response_data,
+ size_t response_data_size) {
+ size_t read_offset = 0;
+ int header_size =
+ net::HttpUtil::LocateEndOfHeaders(response_data, response_data_size);
+ scoped_refptr<net::HttpResponseHeaders> response_headers;
+
+ if (header_size == -1) {
+ LOG(WARNING) << "Can't find headers in result for url: " << final_url;
+ response_headers = new net::HttpResponseHeaders("");
+ } else {
+ response_headers = new net::HttpResponseHeaders(
+ net::HttpUtil::AssembleRawHeaders(response_data, header_size));
+ read_offset = header_size;
+ }
+
+ CHECK_LE(read_offset, response_data_size);
+ OnFetchComplete(final_url, http_response_code, std::move(response_headers),
+ response_data + read_offset,
+ response_data_size - read_offset);
+}
+
+} // namespace headless
« no previous file with comments | « headless/public/util/url_fetcher.h ('k') | headless/public/util/url_request_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698