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