Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "google_apis/drive/base_requests.h" | 5 #include "google_apis/drive/base_requests.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 base::PostTaskAndReplyWithResult( | 88 base::PostTaskAndReplyWithResult( |
| 89 blocking_task_runner, | 89 blocking_task_runner, |
| 90 FROM_HERE, | 90 FROM_HERE, |
| 91 base::Bind(&google_apis::ParseJson, json), | 91 base::Bind(&google_apis::ParseJson, json), |
| 92 callback); | 92 callback); |
| 93 } | 93 } |
| 94 | 94 |
| 95 // Returns response headers as a string. Returns a warning message if | 95 // Returns response headers as a string. Returns a warning message if |
| 96 // |url_fetcher| does not contain a valid response. Used only for debugging. | 96 // |url_fetcher| does not contain a valid response. Used only for debugging. |
| 97 std::string GetResponseHeadersAsString(const URLFetcher* url_fetcher) { | 97 std::string GetResponseHeadersAsString(const URLFetcher* url_fetcher) { |
| 98 // net::HttpResponseHeaders::raw_headers(), as the name implies, stores | |
| 99 // all headers in their raw format, i.e each header is null-terminated. | |
| 100 // So logging raw_headers() only shows the first header, which is probably | |
| 101 // the status line. GetNormalizedHeaders, on the other hand, will show all | |
| 102 // the headers, one per line, which is probably what we want. | |
| 103 std::string headers; | 98 std::string headers; |
| 104 // Check that response code indicates response headers are valid (i.e. not | 99 // Check that response code indicates response headers are valid (i.e. not |
| 105 // malformed) before we retrieve the headers. | 100 // malformed) before we retrieve the headers. |
| 106 if (url_fetcher->GetResponseCode() == URLFetcher::RESPONSE_CODE_INVALID) { | 101 if (url_fetcher->GetResponseCode() == URLFetcher::RESPONSE_CODE_INVALID) { |
| 107 headers.assign("Response headers are malformed!!"); | 102 headers.assign("Response headers are malformed!!"); |
| 108 } else { | 103 } else { |
| 109 url_fetcher->GetResponseHeaders()->GetNormalizedHeaders(&headers); | 104 headers.assign(net::HttpUtil::ConvertHeadersBackToHTTPResponse( |
|
eroman
2017/02/02 03:14:12
Please use assignment here instead:
headers = Co
tfarina
2017/02/13 10:30:26
Done.
| |
| 105 url_fetcher->GetResponseHeaders()->raw_headers())); | |
| 110 } | 106 } |
| 111 return headers; | 107 return headers; |
| 112 } | 108 } |
| 113 | 109 |
| 114 // Obtains the multipart body for the metadata string and file contents. If | 110 // Obtains the multipart body for the metadata string and file contents. If |
| 115 // predetermined_boundary is empty, the function generates the boundary string. | 111 // predetermined_boundary is empty, the function generates the boundary string. |
| 116 bool GetMultipartContent(const std::string& predetermined_boundary, | 112 bool GetMultipartContent(const std::string& predetermined_boundary, |
| 117 const std::string& metadata_json, | 113 const std::string& metadata_json, |
| 118 const std::string& content_type, | 114 const std::string& content_type, |
| 119 const base::FilePath& path, | 115 const base::FilePath& path, |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1004 download_action_callback_.Run(code, temp_file); | 1000 download_action_callback_.Run(code, temp_file); |
| 1005 OnProcessURLFetchResultsComplete(); | 1001 OnProcessURLFetchResultsComplete(); |
| 1006 } | 1002 } |
| 1007 | 1003 |
| 1008 void DownloadFileRequestBase::RunCallbackOnPrematureFailure( | 1004 void DownloadFileRequestBase::RunCallbackOnPrematureFailure( |
| 1009 DriveApiErrorCode code) { | 1005 DriveApiErrorCode code) { |
| 1010 download_action_callback_.Run(code, base::FilePath()); | 1006 download_action_callback_.Run(code, base::FilePath()); |
| 1011 } | 1007 } |
| 1012 | 1008 |
| 1013 } // namespace google_apis | 1009 } // namespace google_apis |
| OLD | NEW |