Returns the bytes content of the response.
(&self, py: Python)
| 126 | |
| 127 | /// Returns the bytes content of the response. |
| 128 | pub fn bytes(&self, py: Python) -> PyResult<Py<PyAny>> { |
| 129 | py.allow_threads(|| { |
| 130 | let resp = self.0.inner()?; |
| 131 | let buffer = pyo3_async_runtimes::tokio::get_runtime() |
| 132 | .block_on(resp.bytes()) |
| 133 | .map(BytesBuffer::new) |
| 134 | .map_err(Error::Request)?; |
| 135 | |
| 136 | Python::with_gil(|py| buffer.into_bytes(py)) |
| 137 | }) |
| 138 | } |
| 139 | |
| 140 | /// Convert the response into a `Stream` of `Bytes` from the body. |
| 141 | pub fn stream(&self, py: Python) -> PyResult<BlockingStreamer> { |