mirror of
https://github.com/matrix-org/pantalaimon.git
synced 2025-01-09 06:37:55 -05:00
daemon: Catch content type errors.
This commit is contained in:
parent
b1444568d4
commit
c57b4c1210
@ -12,6 +12,7 @@ import attr
|
|||||||
import click
|
import click
|
||||||
import logbook
|
import logbook
|
||||||
from aiohttp import ClientSession, web
|
from aiohttp import ClientSession, web
|
||||||
|
from aiohttp.client_exceptions import ContentTypeError
|
||||||
from appdirs import user_data_dir
|
from appdirs import user_data_dir
|
||||||
from logbook import StderrHandler
|
from logbook import StderrHandler
|
||||||
from multidict import CIMultiDict
|
from multidict import CIMultiDict
|
||||||
@ -194,7 +195,7 @@ class ProxyDaemon:
|
|||||||
async def login(self, request):
|
async def login(self, request):
|
||||||
try:
|
try:
|
||||||
body = await request.json()
|
body = await request.json()
|
||||||
except JSONDecodeError:
|
except (JSONDecodeError, ContentTypeError):
|
||||||
# After a long debugging session the culprit ended up being aiohttp
|
# After a long debugging session the culprit ended up being aiohttp
|
||||||
# and a similar bug to
|
# and a similar bug to
|
||||||
# https://github.com/aio-libs/aiohttp/issues/2277 but in the server
|
# https://github.com/aio-libs/aiohttp/issues/2277 but in the server
|
||||||
@ -220,7 +221,7 @@ class ProxyDaemon:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
json_response = await response.json()
|
json_response = await response.json()
|
||||||
except JSONDecodeError:
|
except (JSONDecodeError, ContentTypeError):
|
||||||
json_response = None
|
json_response = None
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -355,7 +356,7 @@ class ProxyDaemon:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
content = await request.json()
|
content = await request.json()
|
||||||
except JSONDecodeError:
|
except (JSONDecodeError, ContentTypeError):
|
||||||
return self._not_json
|
return self._not_json
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user