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

Side by Side Diff: net/test/base_test_server.cc

Issue 10913268: Revert 156742 - Launch pywebsocket via net::TestServer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « net/test/base_test_server.h ('k') | net/test/local_test_server.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
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/base_test_server.h" 5 #include "net/test/base_test_server.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 11 matching lines...) Expand all
22 #include "net/base/net_util.h" 22 #include "net/base/net_util.h"
23 #include "net/base/test_completion_callback.h" 23 #include "net/base/test_completion_callback.h"
24 #include "net/base/test_root_certs.h" 24 #include "net/base/test_root_certs.h"
25 25
26 namespace net { 26 namespace net {
27 27
28 namespace { 28 namespace {
29 29
30 std::string GetHostname(BaseTestServer::Type type, 30 std::string GetHostname(BaseTestServer::Type type,
31 const BaseTestServer::SSLOptions& options) { 31 const BaseTestServer::SSLOptions& options) {
32 if (BaseTestServer::UsingSSL(type) && 32 if ((type == BaseTestServer::TYPE_HTTPS ||
33 type == BaseTestServer::TYPE_WSS) &&
33 options.server_certificate == 34 options.server_certificate ==
34 BaseTestServer::SSLOptions::CERT_MISMATCHED_NAME) { 35 BaseTestServer::SSLOptions::CERT_MISMATCHED_NAME) {
35 // Return a different hostname string that resolves to the same hostname. 36 // Return a different hostname string that resolves to the same hostname.
36 return "localhost"; 37 return "localhost";
37 } 38 }
38 39
39 // Use the 127.0.0.1 as default. 40 // Use the 127.0.0.1 as default.
40 return BaseTestServer::kLocalhost; 41 return BaseTestServer::kLocalhost;
41 } 42 }
42 43
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 started_(false), 120 started_(false),
120 log_to_console_(false) { 121 log_to_console_(false) {
121 Init(host); 122 Init(host);
122 } 123 }
123 124
124 BaseTestServer::BaseTestServer(Type type, const SSLOptions& ssl_options) 125 BaseTestServer::BaseTestServer(Type type, const SSLOptions& ssl_options)
125 : ssl_options_(ssl_options), 126 : ssl_options_(ssl_options),
126 type_(type), 127 type_(type),
127 started_(false), 128 started_(false),
128 log_to_console_(false) { 129 log_to_console_(false) {
129 DCHECK(UsingSSL(type)); 130 DCHECK(type == TYPE_HTTPS || type == TYPE_WSS);
130 Init(GetHostname(type, ssl_options)); 131 Init(GetHostname(type, ssl_options));
131 } 132 }
132 133
133 BaseTestServer::~BaseTestServer() {} 134 BaseTestServer::~BaseTestServer() {}
134 135
135 const HostPortPair& BaseTestServer::host_port_pair() const { 136 const HostPortPair& BaseTestServer::host_port_pair() const {
136 DCHECK(started_); 137 DCHECK(started_);
137 return host_port_pair_; 138 return host_port_pair_;
138 } 139 }
139 140
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 root_certificate_path = src_dir.Append(certificates_dir_); 302 root_certificate_path = src_dir.Append(certificates_dir_);
302 } 303 }
303 304
304 return root_certs->AddFromFile( 305 return root_certs->AddFromFile(
305 root_certificate_path.AppendASCII("root_ca_cert.crt")); 306 root_certificate_path.AppendASCII("root_ca_cert.crt"));
306 } 307 }
307 308
308 bool BaseTestServer::SetupWhenServerStarted() { 309 bool BaseTestServer::SetupWhenServerStarted() {
309 DCHECK(host_port_pair_.port()); 310 DCHECK(host_port_pair_.port());
310 311
311 if (UsingSSL(type_) && !LoadTestRootCert()) 312 if ((type_ == TYPE_HTTPS || type_ == TYPE_WSS) && !LoadTestRootCert())
312 return false; 313 return false;
313 314
314 started_ = true; 315 started_ = true;
315 allowed_port_.reset(new ScopedPortException(host_port_pair_.port())); 316 allowed_port_.reset(new ScopedPortException(host_port_pair_.port()));
316 return true; 317 return true;
317 } 318 }
318 319
319 void BaseTestServer::CleanUpWhenStoppingServer() { 320 void BaseTestServer::CleanUpWhenStoppingServer() {
320 TestRootCerts* root_certs = TestRootCerts::GetInstance(); 321 TestRootCerts* root_certs = TestRootCerts::GetInstance();
321 root_certs->Clear(); 322 root_certs->Clear();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 arguments->Set("https-record-resume", base::Value::CreateNullValue()); 389 arguments->Set("https-record-resume", base::Value::CreateNullValue());
389 if (ssl_options_.tls_intolerant != SSLOptions::TLS_INTOLERANT_NONE) { 390 if (ssl_options_.tls_intolerant != SSLOptions::TLS_INTOLERANT_NONE) {
390 arguments->Set("tls-intolerant", 391 arguments->Set("tls-intolerant",
391 base::Value::CreateIntegerValue(ssl_options_.tls_intolerant)); 392 base::Value::CreateIntegerValue(ssl_options_.tls_intolerant));
392 } 393 }
393 } 394 }
394 return true; 395 return true;
395 } 396 }
396 397
397 } // namespace net 398 } // namespace net
OLDNEW
« no previous file with comments | « net/test/base_test_server.h ('k') | net/test/local_test_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698