summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorpeter@chromium.org <peter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-14 09:38:25 +0000
committerpeter@chromium.org <peter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-14 09:38:25 +0000
commit0beab0474451585b1bd131483e89d04b40c6b88e (patch)
treefbd83d7b8520009d62e85537fd78de436d594b0b /net
parentb2486ad5eff861550673fa11566689187390dc2b (diff)
downloadchromium_src-0beab0474451585b1bd131483e89d04b40c6b88e.zip
chromium_src-0beab0474451585b1bd131483e89d04b40c6b88e.tar.gz
chromium_src-0beab0474451585b1bd131483e89d04b40c6b88e.tar.bz2
Revert 156742 - Launch pywebsocket via net::TestServer
The mod_pywebsocket.standalone module cannot be imported on the Chromium OS bots. Example output is available here: http://build.chromium.org/p/chromium.chromiumos/builders/ChromiumOS%20%28amd64%29/builds/4069/steps/VMTest/logs/stdio BUG=137639 Review URL: https://chromiumcodereview.appspot.com/10879029 TBR=toyoshim@chromium.org Review URL: https://codereview.chromium.org/10913268 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156772 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/test/base_test_server.cc7
-rw-r--r--net/test/base_test_server.h7
-rw-r--r--net/test/local_test_server.cc4
-rw-r--r--net/test/remote_test_server.cc3
-rw-r--r--net/tools/testserver/run_testserver.cc71
-rwxr-xr-xnet/tools/testserver/testserver.py43
6 files changed, 36 insertions, 99 deletions
diff --git a/net/test/base_test_server.cc b/net/test/base_test_server.cc
index e672f19..a4d1ff9 100644
--- a/net/test/base_test_server.cc
+++ b/net/test/base_test_server.cc
@@ -29,7 +29,8 @@ namespace {
std::string GetHostname(BaseTestServer::Type type,
const BaseTestServer::SSLOptions& options) {
- if (BaseTestServer::UsingSSL(type) &&
+ if ((type == BaseTestServer::TYPE_HTTPS ||
+ type == BaseTestServer::TYPE_WSS) &&
options.server_certificate ==
BaseTestServer::SSLOptions::CERT_MISMATCHED_NAME) {
// Return a different hostname string that resolves to the same hostname.
@@ -126,7 +127,7 @@ BaseTestServer::BaseTestServer(Type type, const SSLOptions& ssl_options)
type_(type),
started_(false),
log_to_console_(false) {
- DCHECK(UsingSSL(type));
+ DCHECK(type == TYPE_HTTPS || type == TYPE_WSS);
Init(GetHostname(type, ssl_options));
}
@@ -308,7 +309,7 @@ bool BaseTestServer::LoadTestRootCert() const {
bool BaseTestServer::SetupWhenServerStarted() {
DCHECK(host_port_pair_.port());
- if (UsingSSL(type_) && !LoadTestRootCert())
+ if ((type_ == TYPE_HTTPS || type_ == TYPE_WSS) && !LoadTestRootCert())
return false;
started_ = true;
diff --git a/net/test/base_test_server.h b/net/test/base_test_server.h
index 9f1290e..173abf7 100644
--- a/net/test/base_test_server.h
+++ b/net/test/base_test_server.h
@@ -30,8 +30,6 @@ class BaseTestServer {
public:
typedef std::pair<std::string, std::string> StringPair;
- // Following types represent protocol schemes. See also
- // http://www.iana.org/assignments/uri-schemes.html
enum Type {
TYPE_BASIC_AUTH_PROXY,
TYPE_FTP,
@@ -182,11 +180,6 @@ class BaseTestServer {
const std::vector<StringPair>& text_to_replace,
std::string* replacement_path);
- static bool UsingSSL(Type type) {
- return type == BaseTestServer::TYPE_HTTPS ||
- type == BaseTestServer::TYPE_WSS;
- }
-
protected:
virtual ~BaseTestServer();
Type type() const { return type_; }
diff --git a/net/test/local_test_server.cc b/net/test/local_test_server.cc
index 17137a69..af94a50 100644
--- a/net/test/local_test_server.cc
+++ b/net/test/local_test_server.cc
@@ -176,8 +176,6 @@ bool LocalTestServer::SetPythonPath() {
AppendToPythonPath(third_party_dir.AppendASCII("tlslite"));
AppendToPythonPath(
third_party_dir.AppendASCII("pyftpdlib").AppendASCII("src"));
- AppendToPythonPath(
- third_party_dir.AppendASCII("pywebsocket").AppendASCII("src"));
// Locate the Python code generated by the protocol buffers compiler.
FilePath pyproto_dir;
@@ -231,7 +229,7 @@ bool LocalTestServer::AddCommandLineArguments(CommandLine* command_line) const {
break;
case TYPE_WS:
case TYPE_WSS:
- command_line->AppendArg("--websocket");
+ // TODO(toyoshim): Handle correctly. See, http://crbug.com/137639 .
break;
case TYPE_FTP:
command_line->AppendArg("-f");
diff --git a/net/test/remote_test_server.cc b/net/test/remote_test_server.cc
index 5020ca7..7532945 100644
--- a/net/test/remote_test_server.cc
+++ b/net/test/remote_test_server.cc
@@ -50,9 +50,6 @@ std::string GetServerTypeString(BaseTestServer::Type type) {
case BaseTestServer::TYPE_HTTP:
case BaseTestServer::TYPE_HTTPS:
return "http";
- case BaseTestServer::TYPE_WS:
- case BaseTestServer::TYPE_WSS:
- return "ws";
case BaseTestServer::TYPE_SYNC:
return "sync";
case BaseTestServer::TYPE_TCP_ECHO:
diff --git a/net/tools/testserver/run_testserver.cc b/net/tools/testserver/run_testserver.cc
index 58abe34..9ad0f7d 100644
--- a/net/tools/testserver/run_testserver.cc
+++ b/net/tools/testserver/run_testserver.cc
@@ -18,9 +18,8 @@
#include "net/test/test_server.h"
static void PrintUsage() {
- printf("run_testserver --doc-root=relpath\n"
- " [--http|--https|--ws|--wss|--ftp|--sync]\n"
- " [--ssl-cert=ok|mismatched-name|expired]\n"
+ printf("run_testserver --doc-root=relpath [--http|--https|--ftp|--sync]\n"
+ " [--https-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");
@@ -102,38 +101,21 @@ int main(int argc, const char* argv[]) {
return -1;
}
- net::TestServer::Type server_type;
- if (command_line->HasSwitch("http")) {
- server_type = net::TestServer::TYPE_HTTP;
- } else if (command_line->HasSwitch("https")) {
+ net::TestServer::Type server_type(net::TestServer::TYPE_HTTP);
+ 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("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 (command_line->HasSwitch("https-cert")) {
+ server_type = net::TestServer::TYPE_HTTPS;
+ std::string cert_option = command_line->GetSwitchValueASCII("https-cert");
if (cert_option == "ok") {
ssl_options.server_certificate = net::TestServer::SSLOptions::CERT_OK;
} else if (cert_option == "mismatched-name") {
@@ -143,7 +125,7 @@ int main(int argc, const char* argv[]) {
ssl_options.server_certificate =
net::TestServer::SSLOptions::CERT_EXPIRED;
} else {
- printf("Error: --ssl-cert has invalid value %s\n", cert_option.c_str());
+ printf("Error: --https-cert has invalid value %s\n", cert_option.c_str());
PrintUsage();
return -1;
}
@@ -157,21 +139,30 @@ int main(int argc, const char* argv[]) {
}
scoped_ptr<net::TestServer> test_server;
- 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;
+ 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;
}
- 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()) {
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py
index c4c206a..ff684a8 100755
--- a/net/tools/testserver/testserver.py
+++ b/net/tools/testserver/testserver.py
@@ -19,7 +19,6 @@ import BaseHTTPServer
import cgi
import errno
import httplib
-import logging
import minica
import optparse
import os
@@ -41,7 +40,6 @@ import zlib
warnings.filterwarnings("ignore", category=DeprecationWarning)
import echo_message
-from mod_pywebsocket.standalone import WebSocketServer
import pyftpdlib.ftpserver
import tlslite
import tlslite.api
@@ -67,10 +65,6 @@ SERVER_SYNC = 2
SERVER_TCP_ECHO = 3
SERVER_UDP_ECHO = 4
SERVER_BASIC_AUTH_PROXY = 5
-SERVER_WEBSOCKET = 6
-
-# Default request queue size for WebSocketServer.
-_DEFAULT_REQUEST_QUEUE_SIZE = 128
# Using debug() seems to cause hangs on XP: see http://crbug.com/64515 .
debug_output = sys.stderr
@@ -78,29 +72,6 @@ def debug(str):
debug_output.write(str + "\n")
debug_output.flush()
-class WebSocketOptions:
- """Holds options for WebSocketServer."""
-
- def __init__(self, host, port, data_dir):
- self.request_queue_size = _DEFAULT_REQUEST_QUEUE_SIZE
- self.server_host = host
- self.port = port
- self.websock_handlers = data_dir
- self.scan_dir = None
- self.allow_handlers_outside_root_dir = False
- self.websock_handlers_map_file = None
- self.cgi_directories = []
- self.is_executable_method = None
- self.allow_draft75 = False
- self.strict = True
-
- # TODO(toyoshim): Support SSL and authenticates (http://crbug.com/137639)
- self.use_tls = False
- self.private_key = None
- self.certificate = None
- self.tls_client_ca = None
- self.use_basic_auth = False
-
class RecordingSSLSessionCache(object):
"""RecordingSSLSessionCache acts as a TLS session cache and maintains a log of
lookups and inserts in order to test session cache behaviours."""
@@ -2255,16 +2226,6 @@ def main(options, args):
server.policy_keys = options.policy_keys
server.policy_user = options.policy_user
server.gdata_auth_token = options.auth_token
- elif options.server_type == SERVER_WEBSOCKET:
- # Launch pywebsocket via WebSocketServer.
- logger = logging.getLogger()
- logger.addHandler(logging.StreamHandler())
- # TODO(toyoshim): Remove following os.chdir. Currently this operation
- # is required to work correctly. It should be fixed from pywebsocket side.
- os.chdir(MakeDataDir())
- server = WebSocketServer(WebSocketOptions(host, port, MakeDataDir()))
- print 'WebSocket server started on %s:%d...' % (host, server.server_port)
- server_data['port'] = server.server_port
elif options.server_type == SERVER_SYNC:
xmpp_port = options.xmpp_port
server = SyncHTTPServer((host, port), xmpp_port, SyncPageHandler)
@@ -2369,10 +2330,6 @@ if __name__ == '__main__':
dest='server_type',
help='start up a proxy server which requires basic '
'authentication.')
- option_parser.add_option('', '--websocket', action='store_const',
- const=SERVER_WEBSOCKET, default=SERVER_HTTP,
- dest='server_type',
- help='start up a WebSocket server.')
option_parser.add_option('', '--log-to-console', action='store_const',
const=True, default=False,
dest='log_to_console',