Remove content-specific header fields before changing the request method to GET or HEAD according to RFC 9110, Section 15.4.
(self)
| 397 | return vals[1:] |
| 398 | |
| 399 | def _prepare_for_method_change(self) -> Self: |
| 400 | """ |
| 401 | Remove content-specific header fields before changing the request |
| 402 | method to GET or HEAD according to RFC 9110, Section 15.4. |
| 403 | """ |
| 404 | content_specific_headers = [ |
| 405 | "Content-Encoding", |
| 406 | "Content-Language", |
| 407 | "Content-Location", |
| 408 | "Content-Type", |
| 409 | "Content-Length", |
| 410 | "Digest", |
| 411 | "Last-Modified", |
| 412 | ] |
| 413 | for header in content_specific_headers: |
| 414 | self.discard(header) |
| 415 | return self |
| 416 | |
| 417 | # Backwards compatibility for httplib |
| 418 | getheaders = getlist |