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] )
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)
async def create_response(self, response: Response) -> StarletteResponse: return StarletteResponse(response.body, response.status_code, response.headers)