diff --git a/sanic/headers.py b/sanic/headers.py index 412f2871..b7b75db7 100644 --- a/sanic/headers.py +++ b/sanic/headers.py @@ -178,8 +178,10 @@ def parse_accept(accept: str) -> AcceptList: accorsing to RFC 7231, s. 5.3.2 https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.2 """ + if not accept: + return AcceptList() try: - a = [MediaType._parse(mtype) for mtype in accept.split(",") if mtype] + a = [MediaType._parse(mtype) for mtype in accept.split(",")] return AcceptList(sorted(a, key=lambda mtype: -mtype.q)) except ValueError: raise InvalidHeader(f"Invalid header value in Accept: {accept}")