Commit 9947cc65 authored by Denis Bilenko's avatar Denis Bilenko

wsgi: extract some functionality to pre_start() method, similarly to pywsgi

parent 8c4a6620
...@@ -153,15 +153,18 @@ class WSGIServer(HTTPServer): ...@@ -153,15 +153,18 @@ class WSGIServer(HTTPServer):
def server_port(self): def server_port(self):
return self.address[1] return self.address[1]
def pre_start(self):
env = self.base_env.copy()
env.update( {'SERVER_NAME': socket.getfqdn(self.server_host),
'SERVER_PORT': str(self.server_port) } )
self.base_env = env
def start(self): def start(self):
if self.listeners: if self.listeners:
raise AssertionError('WSGIServer.start() cannot be called more than once') raise AssertionError('WSGIServer.start() cannot be called more than once')
sock = HTTPServer.start(self, self.address, backlog=self.backlog) sock = HTTPServer.start(self, self.address, backlog=self.backlog)
self.address = sock.getsockname() self.address = sock.getsockname()
env = self.base_env.copy() self.pre_start()
env.update( {'SERVER_NAME': socket.getfqdn(self.server_host),
'SERVER_PORT': str(self.server_port) } )
self.base_env = env
return sock return sock
def handle(self, req): def handle(self, req):
......
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