Example #1
0
def convert_responses(response: HttpxResponse) -> StarletteResponse:
    """
    Converts a HttpxResponse to a StarletteResponse
    """
    return StarletteResponse(
        content=response.content,
        status_code=response.status_code,
        headers=response.headers,  # type: ignore[arg-type]
    )
Example #2
0
    async def __call__(self, receive, send):
        body, headers = await self.body
        if self.headers:
            headers.update(self.headers)

        response = StarletteResponse(body,
                                     status_code=self.status_code,
                                     headers=headers)
        await response(receive, send)
Example #3
0
 async def create_response(self, response: Response) -> StarletteResponse:
     return StarletteResponse(response.body, response.status_code,
                              response.headers)