Commit bb74f58e authored by Michael Fladischer's avatar Michael Fladischer

Update upstream source from tag 'upstream/2.2.5'

Update to upstream version '2.2.5'
with Debian dir a833e9e694c088024217762a17618d60c02330f6
parents a3b3c078 e2afd11b
2.2.5 (2019-01-31)
------------------
* WebSocket handshakes are now affected by the websocket connect timeout, so
you can limit them from the command line.
* Server name can now be set using --server-name
2.2.4 (2018-12-15)
------------------
* No longer listens on port 8000 when a file descriptor is provided with --fixed
* No longer listens on port 8000 when a file descriptor is provided with --fd
* Fixed a memory leak with WebSockets
......
__version__ = "2.2.4"
__version__ = "2.2.5"
......@@ -150,6 +150,13 @@ class CommandLineInterface(object):
"application",
help="The application to dispatch to as path.to.module:instance.path",
)
self.parser.add_argument(
"-s",
"--server-name",
dest="server_name",
help="specify which value should be passed to response header Server attribute",
default="Daphne",
)
self.server = None
......@@ -255,6 +262,7 @@ class CommandLineInterface(object):
ping_timeout=args.ping_timeout,
websocket_timeout=args.websocket_timeout,
websocket_connect_timeout=args.websocket_connect_timeout,
websocket_handshake_timeout=args.websocket_connect_timeout,
application_close_timeout=args.application_close_timeout,
action_logger=AccessLogGenerator(access_log_stream)
if access_log_stream
......@@ -267,5 +275,6 @@ class CommandLineInterface(object):
proxy_forwarded_proto_header="X-Forwarded-Proto"
if args.proxy_headers
else None,
server_name=args.server_name,
)
self.server.run()
......@@ -239,6 +239,8 @@ class WebRequest(http.Request):
# Write headers
for header, value in message.get("headers", {}):
self.responseHeaders.addRawHeader(header, value)
if self.server.server_name and self.server.server_name.lower() != "daphne":
self.setHeader(b"server", self.server.server_name.encode("utf-8"))
logger.debug(
"HTTP %s response started for %s", message["status"], self.client_addr
)
......
......@@ -54,6 +54,7 @@ class Server(object):
websocket_handshake_timeout=5,
application_close_timeout=10,
ready_callable=None,
server_name="Daphne",
# Deprecated and does not work, remove in version 2.2
ws_protocols=None,
):
......@@ -77,6 +78,7 @@ class Server(object):
self.verbosity = verbosity
self.abort_start = False
self.ready_callable = ready_callable
self.server_name = server_name
# Check our construction is actually sensible
if not self.endpoints:
logger.error("No endpoints. This server will not listen on anything.")
......@@ -87,7 +89,7 @@ class Server(object):
self.connections = {}
# Make the factory
self.http_factory = HTTPFactory(self)
self.ws_factory = WebSocketFactory(self, server="Daphne")
self.ws_factory = WebSocketFactory(self, server=self.server_name)
self.ws_factory.setProtocolOptions(
autoPingTimeout=self.ping_timeout,
allowNullOrigin=True,
......
......@@ -24,7 +24,9 @@ setup(
include_package_data=True,
install_requires=["twisted>=18.7", "autobahn>=0.18"],
setup_requires=["pytest-runner"],
extras_require={"tests": ["hypothesis", "pytest", "pytest-asyncio~=0.8"]},
extras_require={
"tests": ["hypothesis~=3.88", "pytest~=3.10", "pytest-asyncio~=0.8"]
},
entry_points={
"console_scripts": ["daphne = daphne.cli:CommandLineInterface.entrypoint"]
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment