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

Side by Side Diff: chrome/browser/policy/cloud/test_request_interceptor.cc

Issue 1414983002: Make URLRequestTestJob accept \n terminated header lines. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments mmenke Created 5 years, 1 month 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 | « no previous file | components/certificate_transparency/log_proof_fetcher_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/browser/policy/cloud/test_request_interceptor.h" 5 #include "chrome/browser/policy/cloud/test_request_interceptor.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <queue> 8 #include <queue>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 26 matching lines...) Expand all
37 net::URLRequest* request, 37 net::URLRequest* request,
38 net::NetworkDelegate* network_delegate) { 38 net::NetworkDelegate* network_delegate) {
39 return new net::URLRequestErrorJob(request, network_delegate, error); 39 return new net::URLRequestErrorJob(request, network_delegate, error);
40 } 40 }
41 41
42 // Helper callback for jobs that should fail with a 400 HTTP error. 42 // Helper callback for jobs that should fail with a 400 HTTP error.
43 net::URLRequestJob* BadRequestJobCallback( 43 net::URLRequestJob* BadRequestJobCallback(
44 net::URLRequest* request, 44 net::URLRequest* request,
45 net::NetworkDelegate* network_delegate) { 45 net::NetworkDelegate* network_delegate) {
46 static const char kBadHeaders[] = 46 static const char kBadHeaders[] =
47 "HTTP/1.1 400 Bad request\0" 47 "HTTP/1.1 400 Bad request\n"
48 "Content-type: application/protobuf\0" 48 "Content-type: application/protobuf\n"
49 "\0"; 49 "\n";
50 std::string headers(kBadHeaders, arraysize(kBadHeaders)); 50 std::string headers(kBadHeaders, arraysize(kBadHeaders));
51 return new net::URLRequestTestJob( 51 return new net::URLRequestTestJob(
52 request, network_delegate, headers, std::string(), true); 52 request, network_delegate, headers, std::string(), true);
53 } 53 }
54 54
55 net::URLRequestJob* FileJobCallback(const base::FilePath& file_path, 55 net::URLRequestJob* FileJobCallback(const base::FilePath& file_path,
56 net::URLRequest* request, 56 net::URLRequest* request,
57 net::NetworkDelegate* network_delegate) { 57 net::NetworkDelegate* network_delegate) {
58 return new net::URLRequestMockHTTPJob( 58 return new net::URLRequestMockHTTPJob(
59 request, 59 request,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return BadRequestJobCallback(request, network_delegate); 134 return BadRequestJobCallback(request, network_delegate);
135 135
136 em::DeviceManagementResponse response; 136 em::DeviceManagementResponse response;
137 em::DeviceRegisterResponse* register_response = 137 em::DeviceRegisterResponse* register_response =
138 response.mutable_register_response(); 138 response.mutable_register_response();
139 register_response->set_device_management_token("s3cr3t70k3n"); 139 register_response->set_device_management_token("s3cr3t70k3n");
140 std::string data; 140 std::string data;
141 response.SerializeToString(&data); 141 response.SerializeToString(&data);
142 142
143 static const char kGoodHeaders[] = 143 static const char kGoodHeaders[] =
144 "HTTP/1.1 200 OK\0" 144 "HTTP/1.1 200 OK\n"
145 "Content-type: application/protobuf\0" 145 "Content-type: application/protobuf\n"
146 "\0"; 146 "\n";
147 std::string headers(kGoodHeaders, arraysize(kGoodHeaders)); 147 std::string headers(kGoodHeaders, arraysize(kGoodHeaders));
148 return new net::URLRequestTestJob( 148 return new net::URLRequestTestJob(
149 request, network_delegate, headers, data, true); 149 request, network_delegate, headers, data, true);
150 } 150 }
151 151
152 void RegisterHttpInterceptor( 152 void RegisterHttpInterceptor(
153 const std::string& hostname, 153 const std::string& hostname,
154 scoped_ptr<net::URLRequestInterceptor> interceptor) { 154 scoped_ptr<net::URLRequestInterceptor> interceptor) {
155 net::URLRequestFilter::GetInstance()->AddHostnameInterceptor( 155 net::URLRequestFilter::GetInstance()->AddHostnameInterceptor(
156 "http", hostname, interceptor.Pass()); 156 "http", hostname, interceptor.Pass());
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 FROM_HERE, 333 FROM_HERE,
334 base::Bind( 334 base::Bind(
335 base::IgnoreResult(&base::TaskRunner::PostTask), 335 base::IgnoreResult(&base::TaskRunner::PostTask),
336 base::ThreadTaskRunnerHandle::Get(), 336 base::ThreadTaskRunnerHandle::Get(),
337 FROM_HERE, 337 FROM_HERE,
338 run_loop.QuitClosure())); 338 run_loop.QuitClosure()));
339 run_loop.Run(); 339 run_loop.Run();
340 } 340 }
341 341
342 } // namespace policy 342 } // namespace policy
OLDNEW
« no previous file with comments | « no previous file | components/certificate_transparency/log_proof_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698