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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 NOTREACHED(); | 158 NOTREACHED(); |
159 return std::string(); | 159 return std::string(); |
160 } | 160 } |
161 } | 161 } |
162 | 162 |
163 const char BaseTestServer::kLocalhost[] = "127.0.0.1"; | 163 const char BaseTestServer::kLocalhost[] = "127.0.0.1"; |
164 | 164 |
165 BaseTestServer::BaseTestServer(Type type, const std::string& host) | 165 BaseTestServer::BaseTestServer(Type type, const std::string& host) |
166 : type_(type), | 166 : type_(type), |
167 started_(false), | 167 started_(false), |
168 log_to_console_(false), | 168 log_to_console_(false) { |
169 ws_basic_auth_(false) { | |
170 Init(host); | 169 Init(host); |
171 } | 170 } |
172 | 171 |
173 BaseTestServer::BaseTestServer(Type type, const SSLOptions& ssl_options) | 172 BaseTestServer::BaseTestServer(Type type, const SSLOptions& ssl_options) |
174 : ssl_options_(ssl_options), | 173 : ssl_options_(ssl_options), |
175 type_(type), | 174 type_(type), |
176 started_(false), | 175 started_(false), |
177 log_to_console_(false), | 176 log_to_console_(false) { |
178 ws_basic_auth_(false) { | |
179 DCHECK(UsingSSL(type)); | 177 DCHECK(UsingSSL(type)); |
180 Init(GetHostname(type, ssl_options)); | 178 Init(GetHostname(type, ssl_options)); |
181 } | 179 } |
182 | 180 |
183 BaseTestServer::~BaseTestServer() {} | 181 BaseTestServer::~BaseTestServer() {} |
184 | 182 |
185 const HostPortPair& BaseTestServer::host_port_pair() const { | 183 const HostPortPair& BaseTestServer::host_port_pair() const { |
186 DCHECK(started_); | 184 DCHECK(started_); |
187 return host_port_pair_; | 185 return host_port_pair_; |
188 } | 186 } |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 bool BaseTestServer::GenerateArguments(base::DictionaryValue* arguments) const { | 377 bool BaseTestServer::GenerateArguments(base::DictionaryValue* arguments) const { |
380 DCHECK(arguments); | 378 DCHECK(arguments); |
381 | 379 |
382 arguments->SetString("host", host_port_pair_.host()); | 380 arguments->SetString("host", host_port_pair_.host()); |
383 arguments->SetInteger("port", host_port_pair_.port()); | 381 arguments->SetInteger("port", host_port_pair_.port()); |
384 arguments->SetString("data-dir", document_root_.value()); | 382 arguments->SetString("data-dir", document_root_.value()); |
385 | 383 |
386 if (VLOG_IS_ON(1) || log_to_console_) | 384 if (VLOG_IS_ON(1) || log_to_console_) |
387 arguments->Set("log-to-console", base::Value::CreateNullValue()); | 385 arguments->Set("log-to-console", base::Value::CreateNullValue()); |
388 | 386 |
389 if (ws_basic_auth_) { | |
390 DCHECK(type_ == TYPE_WS || type_ == TYPE_WSS); | |
391 arguments->Set("ws-basic-auth", base::Value::CreateNullValue()); | |
392 } | |
393 | |
394 if (UsingSSL(type_)) { | 387 if (UsingSSL(type_)) { |
395 // Check the certificate arguments of the HTTPS server. | 388 // Check the certificate arguments of the HTTPS server. |
396 base::FilePath certificate_path(certificates_dir_); | 389 base::FilePath certificate_path(certificates_dir_); |
397 base::FilePath certificate_file(ssl_options_.GetCertificateFile()); | 390 base::FilePath certificate_file(ssl_options_.GetCertificateFile()); |
398 if (!certificate_file.value().empty()) { | 391 if (!certificate_file.value().empty()) { |
399 certificate_path = certificate_path.Append(certificate_file); | 392 certificate_path = certificate_path.Append(certificate_file); |
400 if (certificate_path.IsAbsolute() && | 393 if (certificate_path.IsAbsolute() && |
401 !base::PathExists(certificate_path)) { | 394 !base::PathExists(certificate_path)) { |
402 LOG(ERROR) << "Certificate path " << certificate_path.value() | 395 LOG(ERROR) << "Certificate path " << certificate_path.value() |
403 << " doesn't exist. Can't launch https server."; | 396 << " doesn't exist. Can't launch https server."; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 | 473 |
481 return GenerateAdditionalArguments(arguments); | 474 return GenerateAdditionalArguments(arguments); |
482 } | 475 } |
483 | 476 |
484 bool BaseTestServer::GenerateAdditionalArguments( | 477 bool BaseTestServer::GenerateAdditionalArguments( |
485 base::DictionaryValue* arguments) const { | 478 base::DictionaryValue* arguments) const { |
486 return true; | 479 return true; |
487 } | 480 } |
488 | 481 |
489 } // namespace net | 482 } // namespace net |
OLD | NEW |