(response: Response)
| 101 | |
| 102 | |
| 103 | def get_lexer_for_response(response: Response) -> str: |
| 104 | content_type = response.headers.get("Content-Type") |
| 105 | if content_type is not None: |
| 106 | mime_type, _, _ = content_type.partition(";") |
| 107 | try: |
| 108 | return typing.cast( |
| 109 | str, pygments.lexers.get_lexer_for_mimetype(mime_type.strip()).name |
| 110 | ) |
| 111 | except pygments.util.ClassNotFound: # pragma: no cover |
| 112 | pass |
| 113 | return "" # pragma: no cover |
| 114 | |
| 115 | |
| 116 | def format_request_headers(request: httpcore.Request, http2: bool = False) -> str: |