| Index: net/tools/testserver/run_testserver.cc
|
| diff --git a/net/tools/testserver/run_testserver.cc b/net/tools/testserver/run_testserver.cc
|
| index 9ad0f7d98757c559dae78e1dbf3c9c4d5918036a..58abe34dec3c670ef4edbef6af2eec17d1ef030e 100644
|
| --- a/net/tools/testserver/run_testserver.cc
|
| +++ b/net/tools/testserver/run_testserver.cc
|
| @@ -18,8 +18,9 @@
|
| #include "net/test/test_server.h"
|
|
|
| static void PrintUsage() {
|
| - printf("run_testserver --doc-root=relpath [--http|--https|--ftp|--sync]\n"
|
| - " [--https-cert=ok|mismatched-name|expired]\n"
|
| + printf("run_testserver --doc-root=relpath\n"
|
| + " [--http|--https|--ws|--wss|--ftp|--sync]\n"
|
| + " [--ssl-cert=ok|mismatched-name|expired]\n"
|
| " [--port=<port>] [--xmpp-port=<xmpp_port>]\n");
|
| printf("(NOTE: relpath should be relative to the 'src' directory.\n");
|
| printf(" --port and --xmpp-port only work with the --sync flag.)\n");
|
| @@ -101,21 +102,38 @@ int main(int argc, const char* argv[]) {
|
| return -1;
|
| }
|
|
|
| - net::TestServer::Type server_type(net::TestServer::TYPE_HTTP);
|
| - if (command_line->HasSwitch("https")) {
|
| + net::TestServer::Type server_type;
|
| + if (command_line->HasSwitch("http")) {
|
| + server_type = net::TestServer::TYPE_HTTP;
|
| + } else if (command_line->HasSwitch("https")) {
|
| server_type = net::TestServer::TYPE_HTTPS;
|
| + } else if (command_line->HasSwitch("ws")) {
|
| + server_type = net::TestServer::TYPE_WS;
|
| + } else if (command_line->HasSwitch("wss")) {
|
| + server_type = net::TestServer::TYPE_WSS;
|
| } else if (command_line->HasSwitch("ftp")) {
|
| server_type = net::TestServer::TYPE_FTP;
|
| } else if (command_line->HasSwitch("sync")) {
|
| server_type = net::TestServer::TYPE_SYNC;
|
| } else if (command_line->HasSwitch("sync-test")) {
|
| return RunSyncTest() ? 0 : -1;
|
| + } else {
|
| + // If no scheme switch is specified, select http or https scheme.
|
| + // TODO(toyoshim): Remove this estimation.
|
| + if (command_line->HasSwitch("ssl-cert"))
|
| + server_type = net::TestServer::TYPE_HTTPS;
|
| + else
|
| + server_type = net::TestServer::TYPE_HTTP;
|
| }
|
|
|
| net::TestServer::SSLOptions ssl_options;
|
| - if (command_line->HasSwitch("https-cert")) {
|
| - server_type = net::TestServer::TYPE_HTTPS;
|
| - std::string cert_option = command_line->GetSwitchValueASCII("https-cert");
|
| + if (command_line->HasSwitch("ssl-cert")) {
|
| + if (!net::TestServer::UsingSSL(server_type)) {
|
| + printf("Error: --ssl-cert is specified on non-secure scheme\n");
|
| + PrintUsage();
|
| + return -1;
|
| + }
|
| + std::string cert_option = command_line->GetSwitchValueASCII("ssl-cert");
|
| if (cert_option == "ok") {
|
| ssl_options.server_certificate = net::TestServer::SSLOptions::CERT_OK;
|
| } else if (cert_option == "mismatched-name") {
|
| @@ -125,7 +143,7 @@ int main(int argc, const char* argv[]) {
|
| ssl_options.server_certificate =
|
| net::TestServer::SSLOptions::CERT_EXPIRED;
|
| } else {
|
| - printf("Error: --https-cert has invalid value %s\n", cert_option.c_str());
|
| + printf("Error: --ssl-cert has invalid value %s\n", cert_option.c_str());
|
| PrintUsage();
|
| return -1;
|
| }
|
| @@ -139,30 +157,21 @@ int main(int argc, const char* argv[]) {
|
| }
|
|
|
| scoped_ptr<net::TestServer> test_server;
|
| - switch (server_type) {
|
| - case net::TestServer::TYPE_HTTPS: {
|
| - test_server.reset(new net::TestServer(server_type,
|
| - ssl_options,
|
| - doc_root));
|
| - break;
|
| - }
|
| - case net::TestServer::TYPE_SYNC: {
|
| - uint16 port = 0;
|
| - uint16 xmpp_port = 0;
|
| - if (!GetPortFromSwitch("port", &port) ||
|
| - !GetPortFromSwitch("xmpp-port", &xmpp_port)) {
|
| - printf("Error: Could not extract --port and/or --xmpp-port.\n");
|
| - return -1;
|
| - }
|
| - test_server.reset(new net::LocalSyncTestServer(port, xmpp_port));
|
| - break;
|
| - }
|
| - default: {
|
| - test_server.reset(new net::TestServer(server_type,
|
| - net::TestServer::kLocalhost,
|
| - doc_root));
|
| - break;
|
| + if (net::TestServer::UsingSSL(server_type)) {
|
| + test_server.reset(new net::TestServer(server_type, ssl_options, doc_root));
|
| + } else if (server_type == net::TestServer::TYPE_SYNC) {
|
| + uint16 port = 0;
|
| + uint16 xmpp_port = 0;
|
| + if (!GetPortFromSwitch("port", &port) ||
|
| + !GetPortFromSwitch("xmpp-port", &xmpp_port)) {
|
| + printf("Error: Could not extract --port and/or --xmpp-port.\n");
|
| + return -1;
|
| }
|
| + test_server.reset(new net::LocalSyncTestServer(port, xmpp_port));
|
| + } else {
|
| + test_server.reset(new net::TestServer(server_type,
|
| + net::TestServer::kLocalhost,
|
| + doc_root));
|
| }
|
|
|
| if (!test_server->Start()) {
|
|
|