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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "headless/public/util/url_fetcher.h"
6
7 #include <utility>
8
9 #include "base/logging.h"
10 #include "net/http/http_response_headers.h"
11 #include "net/http/http_util.h"
12
13 namespace headless {
14
15 void URLFetcher::ResultListener::OnFetchCompleteExtractHeaders(
16 const GURL& final_url,
17 int http_response_code,
18 const char* response_data,
19 size_t response_data_size) {
20 size_t read_offset = 0;
21 int header_size =
22 net::HttpUtil::LocateEndOfHeaders(response_data, response_data_size);
23 scoped_refptr<net::HttpResponseHeaders> response_headers;
24
25 if (header_size == -1) {
26 LOG(WARNING) << "Can't find headers in result for url: " << final_url;
27 response_headers = new net::HttpResponseHeaders("");
28 } else {
29 response_headers = new net::HttpResponseHeaders(
30 net::HttpUtil::AssembleRawHeaders(response_data, header_size));
31 read_offset = header_size;
32 }
33
34 CHECK_LE(read_offset, response_data_size);
35 OnFetchComplete(final_url, http_response_code, std::move(response_headers),
36 response_data + read_offset,
37 response_data_size - read_offset);
38 }
39
40 } // namespace headless
OLDNEW
« 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