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

Side by Side Diff: net/test/url_request/url_request_mock_http_job.cc

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
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 "net/test/url_request/url_request_mock_http_job.h" 5 #include "net/test/url_request/url_request_mock_http_job.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 task_runner_.get(), 173 task_runner_.get(),
174 FROM_HERE, 174 FROM_HERE,
175 base::Bind(&DoFileIO, file_path_), 175 base::Bind(&DoFileIO, file_path_),
176 base::Bind(&URLRequestMockHTTPJob::SetHeadersAndStart, 176 base::Bind(&URLRequestMockHTTPJob::SetHeadersAndStart,
177 weak_ptr_factory_.GetWeakPtr())); 177 weak_ptr_factory_.GetWeakPtr()));
178 } 178 }
179 179
180 void URLRequestMockHTTPJob::SetHeadersAndStart(const std::string& raw_headers) { 180 void URLRequestMockHTTPJob::SetHeadersAndStart(const std::string& raw_headers) {
181 raw_headers_ = raw_headers; 181 raw_headers_ = raw_headers;
182 // Handle CRLF line-endings. 182 // Handle CRLF line-endings.
183 ReplaceSubstringsAfterOffset(&raw_headers_, 0, "\r\n", "\n"); 183 base::ReplaceSubstringsAfterOffset(&raw_headers_, 0, "\r\n", "\n");
184 // ParseRawHeaders expects \0 to end each header line. 184 // ParseRawHeaders expects \0 to end each header line.
185 ReplaceSubstringsAfterOffset(&raw_headers_, 0, "\n", std::string("\0", 1)); 185 base::ReplaceSubstringsAfterOffset(&raw_headers_, 0, "\n",
186 std::string("\0", 1));
186 URLRequestFileJob::Start(); 187 URLRequestFileJob::Start();
187 } 188 }
188 189
189 // Private const version. 190 // Private const version.
190 void URLRequestMockHTTPJob::GetResponseInfoConst(HttpResponseInfo* info) const { 191 void URLRequestMockHTTPJob::GetResponseInfoConst(HttpResponseInfo* info) const {
191 info->headers = new HttpResponseHeaders(raw_headers_); 192 info->headers = new HttpResponseHeaders(raw_headers_);
192 } 193 }
193 194
194 bool URLRequestMockHTTPJob::GetMimeType(std::string* mime_type) const { 195 bool URLRequestMockHTTPJob::GetMimeType(std::string* mime_type) const {
195 HttpResponseInfo info; 196 HttpResponseInfo info;
(...skipping 10 matching lines...) Expand all
206 return URLRequestJob::GetResponseCode(); 207 return URLRequestJob::GetResponseCode();
207 } 208 }
208 209
209 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { 210 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) {
210 HttpResponseInfo info; 211 HttpResponseInfo info;
211 GetResponseInfo(&info); 212 GetResponseInfo(&info);
212 return info.headers.get() && info.headers->GetCharset(charset); 213 return info.headers.get() && info.headers->GetCharset(charset);
213 } 214 }
214 215
215 } // namespace net 216 } // namespace net
OLDNEW
« no previous file with comments | « net/test/url_request/url_request_failed_job.cc ('k') | net/test/url_request/url_request_slow_download_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698