add websocket secure scheme in request @messense

This commit is contained in:
Jing Su 2017-03-13 18:34:43 +08:00
parent 3af26540ec
commit 250bb7e29d
No known key found for this signature in database
GPG Key ID: D267EFAA88310899

View File

@ -144,12 +144,14 @@ class Request(dict):
def scheme(self): def scheme(self):
if self.app.websocket_enabled \ if self.app.websocket_enabled \
and self.headers.get('upgrade') == 'websocket': and self.headers.get('upgrade') == 'websocket':
return 'ws' scheme = 'ws'
else:
scheme = 'http'
if self.transport.get_extra_info('sslcontext'): if self.transport.get_extra_info('sslcontext'):
return 'https' scheme += 's'
return 'http' return scheme
@property @property
def host(self): def host(self):