summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/tools/testserver/run_testserver.cc37
1 files changed, 31 insertions, 6 deletions
diff --git a/net/tools/testserver/run_testserver.cc b/net/tools/testserver/run_testserver.cc
index 00a765d..53f60d1 100644
--- a/net/tools/testserver/run_testserver.cc
+++ b/net/tools/testserver/run_testserver.cc
@@ -14,7 +14,8 @@
#include "net/test/test_server.h"
static void PrintUsage() {
- printf("run_testserver --doc-root=relpath [--http|--https|--ftp|--sync]\n");
+ printf("run_testserver --doc-root=relpath [--http|--https|--ftp|--sync]\n"
+ " [--https-cert=ok|mismatched-name|expired]\n");
printf("(NOTE: relpath should be relative to the 'src' directory)\n");
}
@@ -52,6 +53,25 @@ int main(int argc, const char* argv[]) {
server_type = net::TestServer::TYPE_SYNC;
}
+ net::TestServer::HTTPSOptions https_options;
+ if (command_line->HasSwitch("https-cert")) {
+ server_type = net::TestServer::TYPE_HTTPS;
+ std::string cert_option = command_line->GetSwitchValueASCII("https-cert");
+ if (cert_option == "ok") {
+ https_options.server_certificate = net::TestServer::HTTPSOptions::CERT_OK;
+ } else if (cert_option == "mismatched-name") {
+ https_options.server_certificate =
+ net::TestServer::HTTPSOptions::CERT_MISMATCHED_NAME;
+ } else if (cert_option == "expired") {
+ https_options.server_certificate =
+ net::TestServer::HTTPSOptions::CERT_EXPIRED;
+ } else {
+ printf("Error: --https-cert has invalid value %s\n", cert_option.c_str());
+ PrintUsage();
+ return -1;
+ }
+ }
+
FilePath doc_root = command_line->GetSwitchValuePath("doc-root");
if ((server_type != net::TestServer::TYPE_SYNC) && doc_root.empty()) {
printf("Error: --doc-root must be specified\n");
@@ -59,20 +79,25 @@ int main(int argc, const char* argv[]) {
return -1;
}
- net::TestServer test_server(server_type, doc_root);
- if (!test_server.Start()) {
+ scoped_ptr<net::TestServer> test_server;
+ if (server_type == net::TestServer::TYPE_HTTPS)
+ test_server.reset(new net::TestServer(https_options, doc_root));
+ else
+ test_server.reset(new net::TestServer(server_type, doc_root));
+
+ if (!test_server->Start()) {
printf("Error: failed to start test server. Exiting.\n");
return -1;
}
- if (!file_util::DirectoryExists(test_server.document_root())) {
+ if (!file_util::DirectoryExists(test_server->document_root())) {
printf("Error: invalid doc root: \"%s\" does not exist!\n",
- UTF16ToUTF8(test_server.document_root().LossyDisplayName()).c_str());
+ UTF16ToUTF8(test_server->document_root().LossyDisplayName()).c_str());
return -1;
}
printf("testserver running at %s (type ctrl+c to exit)\n",
- test_server.host_port_pair().ToString().c_str());
+ test_server->host_port_pair().ToString().c_str());
message_loop.Run();
return 0;