OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "net/test/spawned_test_server/base_test_server.h" | 5 #include "net/test/spawned_test_server/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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 NOTREACHED(); | 141 NOTREACHED(); |
142 return std::string(); | 142 return std::string(); |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
146 const char BaseTestServer::kLocalhost[] = "127.0.0.1"; | 146 const char BaseTestServer::kLocalhost[] = "127.0.0.1"; |
147 | 147 |
148 BaseTestServer::BaseTestServer(Type type, const std::string& host) | 148 BaseTestServer::BaseTestServer(Type type, const std::string& host) |
149 : type_(type), | 149 : type_(type), |
150 started_(false), | 150 started_(false), |
151 log_to_console_(false) { | 151 log_to_console_(false), |
| 152 ws_basic_auth_(false) { |
152 Init(host); | 153 Init(host); |
153 } | 154 } |
154 | 155 |
155 BaseTestServer::BaseTestServer(Type type, const SSLOptions& ssl_options) | 156 BaseTestServer::BaseTestServer(Type type, const SSLOptions& ssl_options) |
156 : ssl_options_(ssl_options), | 157 : ssl_options_(ssl_options), |
157 type_(type), | 158 type_(type), |
158 started_(false), | 159 started_(false), |
159 log_to_console_(false) { | 160 log_to_console_(false), |
| 161 ws_basic_auth_(false) { |
160 DCHECK(UsingSSL(type)); | 162 DCHECK(UsingSSL(type)); |
161 Init(GetHostname(type, ssl_options)); | 163 Init(GetHostname(type, ssl_options)); |
162 } | 164 } |
163 | 165 |
164 BaseTestServer::~BaseTestServer() {} | 166 BaseTestServer::~BaseTestServer() {} |
165 | 167 |
166 const HostPortPair& BaseTestServer::host_port_pair() const { | 168 const HostPortPair& BaseTestServer::host_port_pair() const { |
167 DCHECK(started_); | 169 DCHECK(started_); |
168 return host_port_pair_; | 170 return host_port_pair_; |
169 } | 171 } |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 bool BaseTestServer::GenerateArguments(base::DictionaryValue* arguments) const { | 362 bool BaseTestServer::GenerateArguments(base::DictionaryValue* arguments) const { |
361 DCHECK(arguments); | 363 DCHECK(arguments); |
362 | 364 |
363 arguments->SetString("host", host_port_pair_.host()); | 365 arguments->SetString("host", host_port_pair_.host()); |
364 arguments->SetInteger("port", host_port_pair_.port()); | 366 arguments->SetInteger("port", host_port_pair_.port()); |
365 arguments->SetString("data-dir", document_root_.value()); | 367 arguments->SetString("data-dir", document_root_.value()); |
366 | 368 |
367 if (VLOG_IS_ON(1) || log_to_console_) | 369 if (VLOG_IS_ON(1) || log_to_console_) |
368 arguments->Set("log-to-console", base::Value::CreateNullValue()); | 370 arguments->Set("log-to-console", base::Value::CreateNullValue()); |
369 | 371 |
| 372 if (ws_basic_auth_) { |
| 373 DCHECK(type_ == TYPE_WS || type_ == TYPE_WSS); |
| 374 arguments->Set("ws-basic-auth", base::Value::CreateNullValue()); |
| 375 } |
| 376 |
370 if (UsingSSL(type_)) { | 377 if (UsingSSL(type_)) { |
371 // Check the certificate arguments of the HTTPS server. | 378 // Check the certificate arguments of the HTTPS server. |
372 base::FilePath certificate_path(certificates_dir_); | 379 base::FilePath certificate_path(certificates_dir_); |
373 base::FilePath certificate_file(ssl_options_.GetCertificateFile()); | 380 base::FilePath certificate_file(ssl_options_.GetCertificateFile()); |
374 if (!certificate_file.value().empty()) { | 381 if (!certificate_file.value().empty()) { |
375 certificate_path = certificate_path.Append(certificate_file); | 382 certificate_path = certificate_path.Append(certificate_file); |
376 if (certificate_path.IsAbsolute() && | 383 if (certificate_path.IsAbsolute() && |
377 !base::PathExists(certificate_path)) { | 384 !base::PathExists(certificate_path)) { |
378 LOG(ERROR) << "Certificate path " << certificate_path.value() | 385 LOG(ERROR) << "Certificate path " << certificate_path.value() |
379 << " doesn't exist. Can't launch https server."; | 386 << " doesn't exist. Can't launch https server."; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 | 461 |
455 return GenerateAdditionalArguments(arguments); | 462 return GenerateAdditionalArguments(arguments); |
456 } | 463 } |
457 | 464 |
458 bool BaseTestServer::GenerateAdditionalArguments( | 465 bool BaseTestServer::GenerateAdditionalArguments( |
459 base::DictionaryValue* arguments) const { | 466 base::DictionaryValue* arguments) const { |
460 return true; | 467 return true; |
461 } | 468 } |
462 | 469 |
463 } // namespace net | 470 } // namespace net |
OLD | NEW |