Back to Bolt Python

slack_bolt.adapter.asgi.http_response API documentation

docs/reference/adapter/asgi/http_response.html

1.28.04.6 KB
Original Source

Classes

class AsgiHttpResponse (status: int, headers: Dict[str, Sequence[str]] = {}, body: str = '')#Expand source code

class AsgiHttpResponse:
    __slots__ = ("status", "raw_headers", "body")

    def __init__ (self, status: int, headers: Dict[str, Sequence[str]] = {}, body: str = ""):
        self.status: int = status
        self.raw_headers: List[Tuple[bytes, bytes]] = [
            (bytes(key, ENCODING), bytes(value[0], ENCODING)) for key, value in headers.items()
        ]
        self.raw_headers.append((b"content-length", bytes(str(len(body)), ENCODING)))
        self.body: bytes = bytes(body, ENCODING)

    def get_response_start(self) -> Dict[str, Union[str, int, Iterable[Tuple[bytes, bytes]]]]:
        return {
            "type": "http.response.start",
            "status": self.status,
            "headers": self.raw_headers,
        }

    def get_response_body(self) -> Dict[str, Union[str, bytes, bool]]:
        return {
            "type": "http.response.body",
            "body": self.body,
            "more_body": False,
        }

Instance variables

var body#Expand source code

class AsgiHttpResponse:
    __slots__ = ("status", "raw_headers", "body")

    def __init__ (self, status: int, headers: Dict[str, Sequence[str]] = {}, body: str = ""):
        self.status: int = status
        self.raw_headers: List[Tuple[bytes, bytes]] = [
            (bytes(key, ENCODING), bytes(value[0], ENCODING)) for key, value in headers.items()
        ]
        self.raw_headers.append((b"content-length", bytes(str(len(body)), ENCODING)))
        self.body: bytes = bytes(body, ENCODING)

    def get_response_start(self) -> Dict[str, Union[str, int, Iterable[Tuple[bytes, bytes]]]]:
        return {
            "type": "http.response.start",
            "status": self.status,
            "headers": self.raw_headers,
        }

    def get_response_body(self) -> Dict[str, Union[str, bytes, bool]]:
        return {
            "type": "http.response.body",
            "body": self.body,
            "more_body": False,
        }

var raw_headers#Expand source code

class AsgiHttpResponse:
    __slots__ = ("status", "raw_headers", "body")

    def __init__ (self, status: int, headers: Dict[str, Sequence[str]] = {}, body: str = ""):
        self.status: int = status
        self.raw_headers: List[Tuple[bytes, bytes]] = [
            (bytes(key, ENCODING), bytes(value[0], ENCODING)) for key, value in headers.items()
        ]
        self.raw_headers.append((b"content-length", bytes(str(len(body)), ENCODING)))
        self.body: bytes = bytes(body, ENCODING)

    def get_response_start(self) -> Dict[str, Union[str, int, Iterable[Tuple[bytes, bytes]]]]:
        return {
            "type": "http.response.start",
            "status": self.status,
            "headers": self.raw_headers,
        }

    def get_response_body(self) -> Dict[str, Union[str, bytes, bool]]:
        return {
            "type": "http.response.body",
            "body": self.body,
            "more_body": False,
        }

var status#Expand source code

class AsgiHttpResponse:
    __slots__ = ("status", "raw_headers", "body")

    def __init__ (self, status: int, headers: Dict[str, Sequence[str]] = {}, body: str = ""):
        self.status: int = status
        self.raw_headers: List[Tuple[bytes, bytes]] = [
            (bytes(key, ENCODING), bytes(value[0], ENCODING)) for key, value in headers.items()
        ]
        self.raw_headers.append((b"content-length", bytes(str(len(body)), ENCODING)))
        self.body: bytes = bytes(body, ENCODING)

    def get_response_start(self) -> Dict[str, Union[str, int, Iterable[Tuple[bytes, bytes]]]]:
        return {
            "type": "http.response.start",
            "status": self.status,
            "headers": self.raw_headers,
        }

    def get_response_body(self) -> Dict[str, Union[str, bytes, bool]]:
        return {
            "type": "http.response.body",
            "body": self.body,
            "more_body": False,
        }

Methods

def get_response_body(self) ‑> Dict[str, str | bytes | bool]#Expand source code

def get_response_body(self) -> Dict[str, Union[str, bytes, bool]]:
    return {
        "type": "http.response.body",
        "body": self.body,
        "more_body": False,
    }

def get_response_start(self) ‑> Dict[str, str | int | Iterable[Tuple[bytes, bytes]]]#Expand source code

def get_response_start(self) -> Dict[str, Union[str, int, Iterable[Tuple[bytes, bytes]]]]:
    return {
        "type": "http.response.start",
        "status": self.status,
        "headers": self.raw_headers,
    }