| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/test_server.h" | 5 #include "net/test/test_server.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 case CERT_EXPIRED: | 80 case CERT_EXPIRED: |
| 81 return FilePath(FILE_PATH_LITERAL("expired_cert.pem")); | 81 return FilePath(FILE_PATH_LITERAL("expired_cert.pem")); |
| 82 default: | 82 default: |
| 83 NOTREACHED(); | 83 NOTREACHED(); |
| 84 } | 84 } |
| 85 return FilePath(); | 85 return FilePath(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 TestServer::TestServer(Type type, const FilePath& document_root) | 88 TestServer::TestServer(Type type, const FilePath& document_root) |
| 89 : type_(type), | 89 : type_(type), |
| 90 started_(false) { | 90 started_(false), |
| 91 log_to_console_(true) { |
| 91 Init(document_root); | 92 Init(document_root); |
| 92 } | 93 } |
| 93 | 94 |
| 94 TestServer::TestServer(const HTTPSOptions& https_options, | 95 TestServer::TestServer(const HTTPSOptions& https_options, |
| 95 const FilePath& document_root) | 96 const FilePath& document_root) |
| 96 : https_options_(https_options), | 97 : https_options_(https_options), |
| 97 type_(TYPE_HTTPS), | 98 type_(TYPE_HTTPS), |
| 98 started_(false) { | 99 started_(false), |
| 100 log_to_console_(true) { |
| 99 Init(document_root); | 101 Init(document_root); |
| 100 } | 102 } |
| 101 | 103 |
| 102 TestServer::~TestServer() { | 104 TestServer::~TestServer() { |
| 103 TestRootCerts* root_certs = TestRootCerts::GetInstance(); | 105 TestRootCerts* root_certs = TestRootCerts::GetInstance(); |
| 104 root_certs->Clear(); | 106 root_certs->Clear(); |
| 105 Stop(); | 107 Stop(); |
| 106 } | 108 } |
| 107 | 109 |
| 108 bool TestServer::Start() { | 110 bool TestServer::Start() { |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 bool TestServer::LoadTestRootCert() { | 340 bool TestServer::LoadTestRootCert() { |
| 339 TestRootCerts* root_certs = TestRootCerts::GetInstance(); | 341 TestRootCerts* root_certs = TestRootCerts::GetInstance(); |
| 340 return root_certs->AddFromFile(GetRootCertificatePath()); | 342 return root_certs->AddFromFile(GetRootCertificatePath()); |
| 341 } | 343 } |
| 342 | 344 |
| 343 bool TestServer::AddCommandLineArguments(CommandLine* command_line) const { | 345 bool TestServer::AddCommandLineArguments(CommandLine* command_line) const { |
| 344 command_line->AppendSwitchASCII("port", | 346 command_line->AppendSwitchASCII("port", |
| 345 base::IntToString(host_port_pair_.port())); | 347 base::IntToString(host_port_pair_.port())); |
| 346 command_line->AppendSwitchPath("data-dir", document_root_); | 348 command_line->AppendSwitchPath("data-dir", document_root_); |
| 347 | 349 |
| 350 if (log_to_console_) { |
| 351 command_line->AppendArg("--log-to-console"); |
| 352 } |
| 353 |
| 348 if (type_ == TYPE_FTP) { | 354 if (type_ == TYPE_FTP) { |
| 349 command_line->AppendArg("-f"); | 355 command_line->AppendArg("-f"); |
| 350 } else if (type_ == TYPE_SYNC) { | 356 } else if (type_ == TYPE_SYNC) { |
| 351 command_line->AppendArg("--sync"); | 357 command_line->AppendArg("--sync"); |
| 352 } else if (type_ == TYPE_HTTPS) { | 358 } else if (type_ == TYPE_HTTPS) { |
| 353 FilePath certificate_path(certificates_dir_); | 359 FilePath certificate_path(certificates_dir_); |
| 354 certificate_path = certificate_path.Append( | 360 certificate_path = certificate_path.Append( |
| 355 https_options_.GetCertificateFile()); | 361 https_options_.GetCertificateFile()); |
| 356 if (!file_util::PathExists(certificate_path)) { | 362 if (!file_util::PathExists(certificate_path)) { |
| 357 LOG(ERROR) << "Certificate path " << certificate_path.value() | 363 LOG(ERROR) << "Certificate path " << certificate_path.value() |
| (...skipping 25 matching lines...) Expand all Loading... |
| 383 if (https_options_.bulk_ciphers & HTTPSOptions::BULK_CIPHER_AES256) | 389 if (https_options_.bulk_ciphers & HTTPSOptions::BULK_CIPHER_AES256) |
| 384 command_line->AppendSwitchASCII(kBulkCipherSwitch, "aes256"); | 390 command_line->AppendSwitchASCII(kBulkCipherSwitch, "aes256"); |
| 385 if (https_options_.bulk_ciphers & HTTPSOptions::BULK_CIPHER_3DES) | 391 if (https_options_.bulk_ciphers & HTTPSOptions::BULK_CIPHER_3DES) |
| 386 command_line->AppendSwitchASCII(kBulkCipherSwitch, "3des"); | 392 command_line->AppendSwitchASCII(kBulkCipherSwitch, "3des"); |
| 387 } | 393 } |
| 388 | 394 |
| 389 return true; | 395 return true; |
| 390 } | 396 } |
| 391 | 397 |
| 392 } // namespace net | 398 } // namespace net |
| OLD | NEW |