| 109 | /// Encoding to decode with when accessing text. |
| 110 | #[getter] |
| 111 | pub fn encoding(&self, py: Python) -> String { |
| 112 | py.allow_threads(|| { |
| 113 | self.headers |
| 114 | .0 |
| 115 | .get(header::CONTENT_TYPE) |
| 116 | .and_then(|value| value.to_str().ok()) |
| 117 | .and_then(|value| value.parse::<Mime>().ok()) |
| 118 | .and_then(|mime| { |
| 119 | mime.get_param("charset") |
| 120 | .map(|charset| charset.as_str().to_owned()) |
| 121 | }) |
| 122 | .unwrap_or_else(|| "utf-8".to_owned()) |
| 123 | }) |
| 124 | } |
| 125 | |
| 126 | /// Returns the TLS peer certificate of the response. |
| 127 | pub fn peer_certificate<'py>( |