Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: net/tools/testserver/testserver.py

Issue 312593002: Print out the scheme in the test server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """This is a simple HTTP/FTP/TCP/UDP/BASIC_AUTH_PROXY/WEBSOCKET server used for 6 """This is a simple HTTP/FTP/TCP/UDP/BASIC_AUTH_PROXY/WEBSOCKET server used for
7 testing Chrome. 7 testing Chrome.
8 8
9 It supports several test URLs, as specified by the handlers in TestPageHandler. 9 It supports several test URLs, as specified by the handlers in TestPageHandler.
10 By default, it listens on an ephemeral port and sends the port number back to 10 By default, it listens on an ephemeral port and sends the port number back to
(...skipping 1992 matching lines...) Expand 10 before | Expand all | Expand 10 after
2003 self.options.ssl_client_cert_type, 2003 self.options.ssl_client_cert_type,
2004 self.options.ssl_bulk_cipher, 2004 self.options.ssl_bulk_cipher,
2005 self.options.ssl_key_exchange, 2005 self.options.ssl_key_exchange,
2006 self.options.enable_npn, 2006 self.options.enable_npn,
2007 self.options.record_resume, 2007 self.options.record_resume,
2008 self.options.tls_intolerant, 2008 self.options.tls_intolerant,
2009 self.options.signed_cert_timestamps_tls_ext.decode( 2009 self.options.signed_cert_timestamps_tls_ext.decode(
2010 "base64"), 2010 "base64"),
2011 self.options.fallback_scsv, 2011 self.options.fallback_scsv,
2012 stapled_ocsp_response) 2012 stapled_ocsp_response)
2013 print 'HTTPS server started on %s:%d...' % (host, server.server_port) 2013 print 'HTTPS server started on https://%s:%d...' % \
2014 (host, server.server_port)
2014 else: 2015 else:
2015 server = HTTPServer((host, port), TestPageHandler) 2016 server = HTTPServer((host, port), TestPageHandler)
2016 print 'HTTP server started on %s:%d...' % (host, server.server_port) 2017 print 'HTTP server started on http://%s:%d...' % \
2018 (host, server.server_port)
2017 2019
2018 server.data_dir = self.__make_data_dir() 2020 server.data_dir = self.__make_data_dir()
2019 server.file_root_url = self.options.file_root_url 2021 server.file_root_url = self.options.file_root_url
2020 server_data['port'] = server.server_port 2022 server_data['port'] = server.server_port
2021 elif self.options.server_type == SERVER_WEBSOCKET: 2023 elif self.options.server_type == SERVER_WEBSOCKET:
2022 # Launch pywebsocket via WebSocketServer. 2024 # Launch pywebsocket via WebSocketServer.
2023 logger = logging.getLogger() 2025 logger = logging.getLogger()
2024 logger.addHandler(logging.StreamHandler()) 2026 logger.addHandler(logging.StreamHandler())
2025 # TODO(toyoshim): Remove following os.chdir. Currently this operation 2027 # TODO(toyoshim): Remove following os.chdir. Currently this operation
2026 # is required to work correctly. It should be fixed from pywebsocket side. 2028 # is required to work correctly. It should be fixed from pywebsocket side.
2027 os.chdir(self.__make_data_dir()) 2029 os.chdir(self.__make_data_dir())
2028 websocket_options = WebSocketOptions(host, port, '.') 2030 websocket_options = WebSocketOptions(host, port, '.')
2031 scheme = "ws"
2029 if self.options.cert_and_key_file: 2032 if self.options.cert_and_key_file:
2033 scheme = "wss"
2030 websocket_options.use_tls = True 2034 websocket_options.use_tls = True
2031 websocket_options.private_key = self.options.cert_and_key_file 2035 websocket_options.private_key = self.options.cert_and_key_file
2032 websocket_options.certificate = self.options.cert_and_key_file 2036 websocket_options.certificate = self.options.cert_and_key_file
2033 if self.options.ssl_client_auth: 2037 if self.options.ssl_client_auth:
2034 websocket_options.tls_client_auth = True 2038 websocket_options.tls_client_auth = True
2035 if len(self.options.ssl_client_ca) != 1: 2039 if len(self.options.ssl_client_ca) != 1:
2036 raise testserver_base.OptionError( 2040 raise testserver_base.OptionError(
2037 'one trusted client CA file should be specified') 2041 'one trusted client CA file should be specified')
2038 if not os.path.isfile(self.options.ssl_client_ca[0]): 2042 if not os.path.isfile(self.options.ssl_client_ca[0]):
2039 raise testserver_base.OptionError( 2043 raise testserver_base.OptionError(
2040 'specified trusted client CA file not found: ' + 2044 'specified trusted client CA file not found: ' +
2041 self.options.ssl_client_ca[0] + ' exiting...') 2045 self.options.ssl_client_ca[0] + ' exiting...')
2042 websocket_options.tls_client_ca = self.options.ssl_client_ca[0] 2046 websocket_options.tls_client_ca = self.options.ssl_client_ca[0]
2043 server = WebSocketServer(websocket_options) 2047 server = WebSocketServer(websocket_options)
2044 print 'WebSocket server started on %s:%d...' % (host, server.server_port) 2048 print 'WebSocket server started on %s://%s:%d...' % \
2049 (scheme, host, server.server_port)
2045 server_data['port'] = server.server_port 2050 server_data['port'] = server.server_port
2046 elif self.options.server_type == SERVER_TCP_ECHO: 2051 elif self.options.server_type == SERVER_TCP_ECHO:
2047 # Used for generating the key (randomly) that encodes the "echo request" 2052 # Used for generating the key (randomly) that encodes the "echo request"
2048 # message. 2053 # message.
2049 random.seed() 2054 random.seed()
2050 server = TCPEchoServer((host, port), TCPEchoHandler) 2055 server = TCPEchoServer((host, port), TCPEchoHandler)
2051 print 'Echo TCP server started on port %d...' % server.server_port 2056 print 'Echo TCP server started on port %d...' % server.server_port
2052 server_data['port'] = server.server_port 2057 server_data['port'] = server.server_port
2053 elif self.options.server_type == SERVER_UDP_ECHO: 2058 elif self.options.server_type == SERVER_UDP_ECHO:
2054 # Used for generating the key (randomly) that encodes the "echo request" 2059 # Used for generating the key (randomly) that encodes the "echo request"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
2215 action='store_const', 2220 action='store_const',
2216 help='Enable server support for the NPN ' 2221 help='Enable server support for the NPN '
2217 'extension. The server will advertise ' 2222 'extension. The server will advertise '
2218 'support for exactly one protocol, http/1.1') 2223 'support for exactly one protocol, http/1.1')
2219 self.option_parser.add_option('--file-root-url', default='/files/', 2224 self.option_parser.add_option('--file-root-url', default='/files/',
2220 help='Specify a root URL for files served.') 2225 help='Specify a root URL for files served.')
2221 2226
2222 2227
2223 if __name__ == '__main__': 2228 if __name__ == '__main__':
2224 sys.exit(ServerRunner().main()) 2229 sys.exit(ServerRunner().main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698