diff --git a/src/byteb4rb1e/utils/http/client.py b/src/byteb4rb1e/utils/http/client.py index 0962445..02b8cb6 100644 --- a/src/byteb4rb1e/utils/http/client.py +++ b/src/byteb4rb1e/utils/http/client.py @@ -5,6 +5,7 @@ Thin urllib wrapper with retry-on-rate-limit. No domain knowledge — GitHub, Bitbucket, etc. are handled by higher-level modules. """ +from dataclasses import dataclass import json import time from typing import Any, Dict, Optional @@ -13,17 +14,20 @@ import urllib.parse from warnings import warn +@dataclass(frozen=True) class HttpResponse: - def __init__(self, status: int, headers: dict, data: bytes, reason: str): - self.status_code = status - self.headers = headers - self.data = data - self.reason = reason - self.text = data.decode("utf-8", errors="replace") + status_code: int + headers: dict[str, str] + data: bytes + reason: Optional[str] = None def json(self): return json.loads(self.data.decode("utf-8")) + @property + def text(self) -> str: + return self.data.decode("utf-8", errors="replace") + def _request( url: str,