[util] add 'NullResponse' class

This commit is contained in:
Mike Fährmann
2025-05-29 20:27:40 +02:00
parent 539ed8fef4
commit 002c25d417
2 changed files with 43 additions and 0 deletions

View File

@@ -639,6 +639,28 @@ class NullContext():
pass
class NullResponse():
__slots__ = ("url", "reason")
ok = is_redirect = is_permanent_redirect = False
cookies = headers = history = links = {}
encoding = apparent_encoding = "utf-8"
content = b""
text = ""
status_code = 900
close = noop
def __init__(self, url, reason=""):
self.url = url
self.reason = str(reason)
def __str__(self):
return "900 " + self.reason
def json(self):
return {}
class CustomNone():
"""None-style type that supports more operations than regular None"""
__slots__ = ()