Module slack_sdk.http_retry.request

Classes

class HttpRequest (*,
method: str,
url: str,
headers: Dict[str, str | List[str]],
body_params: Dict[str, Any] | None = None,
data: bytes | None = None)

HTTP request representation

Expand source code
class HttpRequest:
    """HTTP request representation"""

    method: str
    url: str
    headers: Dict[str, Union[str, List[str]]]
    body_params: Optional[Dict[str, Any]]
    data: Optional[bytes]

    def __init__(
        self,
        *,
        method: str,
        url: str,
        headers: Dict[str, Union[str, List[str]]],
        body_params: Optional[Dict[str, Any]] = None,
        data: Optional[bytes] = None,
    ):
        self.method = method
        self.url = url
        self.headers = {k: v if isinstance(v, list) else [v] for k, v in headers.items()}
        self.body_params = body_params
        self.data = data

    @classmethod
    def from_urllib_http_request(cls, req: Request) -> "HttpRequest":
        return HttpRequest(
            method=req.method,
            url=req.full_url,
            headers={k: v if isinstance(v, list) else [v] for k, v in req.headers.items()},
            data=req.data,
        )

Class variables

var body_params : Dict[str, Any] | None

The type of the None singleton.

var data : bytes | None

The type of the None singleton.

var headers : Dict[str, str | List[str]]

The type of the None singleton.

var method : str

The type of the None singleton.

var url : str

The type of the None singleton.

Static methods

def from_urllib_http_request(req: urllib.request.Request) ‑> HttpRequest