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: if response is not None:
try: try:
response = await request.respond(response) response = await request.respond(response)
except: except BaseException:
# Skip response middleware # Skip response middleware
request.stream.respond(response) request.stream.respond(response)
await response.send(end_stream=True) await response.send(end_stream=True)

View File

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

View File

@ -145,7 +145,7 @@ class Http:
request = self.protocol.request_class( request = self.protocol.request_class(
url_bytes=self.url.encode(), url_bytes=self.url.encode(),
headers=Header(headers), headers=Header(headers),
version=protocol[-3:], version=protocol[5:],
method=method, method=method,
transport=self.protocol.transport, transport=self.protocol.transport,
app=self.protocol.app, 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 httptools import parse_url # type: ignore
from sanic.exceptions import InvalidUsage
from sanic.compat import CancelledErrors from sanic.compat import CancelledErrors
from sanic.exceptions import InvalidUsage
from sanic.headers import ( from sanic.headers import (
parse_content_header, parse_content_header,
parse_forwarded, parse_forwarded,
@ -17,7 +17,7 @@ from sanic.headers import (
parse_xforwarded, parse_xforwarded,
) )
from sanic.log import error_logger, logger from sanic.log import error_logger, logger
from sanic.response import HTTPResponse, BaseHTTPResponse from sanic.response import BaseHTTPResponse, HTTPResponse
try: try:
@ -128,8 +128,7 @@ class Request:
raise raise
except Exception: except Exception:
error_logger.exception( error_logger.exception(
"Exception occurred in one of response " "Exception occurred in one of response middleware handlers"
"middleware handlers"
) )
return response return response