This commit is contained in:
L. Kärkkäinen 2020-03-10 17:02:26 +02:00
parent 17d100400f
commit 9098493da9
4 changed files with 10 additions and 8 deletions

View File

@ -958,7 +958,7 @@ class Sanic:
if response is not None:
try:
response = await request.respond(response)
except:
except BaseException:
# Skip response middleware
request.stream.respond(response)
await response.send(end_stream=True)

View File

@ -1,13 +1,16 @@
from asyncio import CancelledError
from sys import argv
from multidict import CIMultiDict # type: ignore
from asyncio import CancelledError
try:
from trio import Cancelled
CancelledErrors = CancelledError, Cancelled
except ImportError:
CancelledErrors = CancelledError,
CancelledErrors = (CancelledError,)
class Header(CIMultiDict):
def get_all(self, key):

View File

@ -145,7 +145,7 @@ class Http:
request = self.protocol.request_class(
url_bytes=self.url.encode(),
headers=Header(headers),
version=protocol[-3:],
version=protocol[5:],
method=method,
transport=self.protocol.transport,
app=self.protocol.app,

View File

@ -8,8 +8,8 @@ from urllib.parse import parse_qs, parse_qsl, unquote, urlunparse
from httptools import parse_url # type: ignore
from sanic.exceptions import InvalidUsage
from sanic.compat import CancelledErrors
from sanic.exceptions import InvalidUsage
from sanic.headers import (
parse_content_header,
parse_forwarded,
@ -17,7 +17,7 @@ from sanic.headers import (
parse_xforwarded,
)
from sanic.log import error_logger, logger
from sanic.response import HTTPResponse, BaseHTTPResponse
from sanic.response import BaseHTTPResponse, HTTPResponse
try:
@ -128,8 +128,7 @@ class Request:
raise
except Exception:
error_logger.exception(
"Exception occurred in one of response "
"middleware handlers"
"Exception occurred in one of response middleware handlers"
)
return response