Merge pull request #549 from ai0/websocket-scheme

add websocket scheme in request
This commit is contained in:
Raphael Deem 2017-03-13 16:59:47 -07:00 committed by GitHub
commit 6984f6eec4
2 changed files with 10 additions and 4 deletions

View File

@ -57,7 +57,7 @@ Blueprints have much the same functionality as an application instance.
### WebSocket routes ### WebSocket routes
WebSocket handlers can be registered on a blueprint using the `@bp.route` WebSocket handlers can be registered on a blueprint using the `@bp.websocket`
decorator or `bp.add_websocket_route` method. decorator or `bp.add_websocket_route` method.
### Middleware ### Middleware

View File

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