bugfix: fix incompatible api between multidict and websockets, and bump up websockets version to match uvicorn

This commit is contained in:
Yun Xu 2019-07-18 19:57:17 -07:00
parent 84b41123f2
commit b397637bb9
4 changed files with 11 additions and 4 deletions

7
sanic/compat.py Normal file
View File

@ -0,0 +1,7 @@
from multidict import CIMultiDict
class Header(CIMultiDict):
def get_all(self, key):
return self.getall(key, [])

View File

@ -12,8 +12,8 @@ from time import time
from httptools import HttpRequestParser from httptools import HttpRequestParser
from httptools.parser.errors import HttpParserError from httptools.parser.errors import HttpParserError
from multidict import CIMultiDict
from sanic.compat import Header
from sanic.exceptions import ( from sanic.exceptions import (
HeaderExpectationFailed, HeaderExpectationFailed,
InvalidUsage, InvalidUsage,
@ -304,7 +304,7 @@ class HttpProtocol(asyncio.Protocol):
def on_headers_complete(self): def on_headers_complete(self):
self.request = self.request_class( self.request = self.request_class(
url_bytes=self.url, url_bytes=self.url,
headers=CIMultiDict(self.headers), headers=Header(self.headers),
version=self.parser.get_http_version(), version=self.parser.get_http_version(),
method=self.parser.get_method().decode(), method=self.parser.get_method().decode(),
transport=self.transport, transport=self.transport,

View File

@ -80,7 +80,7 @@ requirements = [
uvloop, uvloop,
ujson, ujson,
"aiofiles>=0.3.0", "aiofiles>=0.3.0",
"websockets>=6.0,<7.0", "websockets>=7.0,<8.0",
"multidict>=4.0,<5.0", "multidict>=4.0,<5.0",
"requests-async==0.5.0", "requests-async==0.5.0",
] ]

View File

@ -19,7 +19,7 @@ deps =
gunicorn gunicorn
pytest-benchmark pytest-benchmark
uvicorn uvicorn
websockets>=6.0,<7.0 websockets>=7.0,<8.0
commands = commands =
pytest {posargs:tests --cov sanic} pytest {posargs:tests --cov sanic}
- coverage combine --append - coverage combine --append