Return the escaping scheme from the Accept header. If no escaping scheme is specified or the scheme is not one of the allowed strings, defaults to UNDERSCORES.
(accept_header: List[str])
| 384 | |
| 385 | |
| 386 | def _get_escaping(accept_header: List[str]) -> str: |
| 387 | """Return the escaping scheme from the Accept header. |
| 388 | |
| 389 | If no escaping scheme is specified or the scheme is not one of the allowed |
| 390 | strings, defaults to UNDERSCORES.""" |
| 391 | |
| 392 | for tok in accept_header: |
| 393 | if '=' not in tok: |
| 394 | continue |
| 395 | key, value = tok.strip().split('=', 1) |
| 396 | if key != 'escaping': |
| 397 | continue |
| 398 | if value == openmetrics.ALLOWUTF8: |
| 399 | return openmetrics.ALLOWUTF8 |
| 400 | elif value == openmetrics.UNDERSCORES: |
| 401 | return openmetrics.UNDERSCORES |
| 402 | elif value == openmetrics.DOTS: |
| 403 | return openmetrics.DOTS |
| 404 | elif value == openmetrics.VALUES: |
| 405 | return openmetrics.VALUES |
| 406 | else: |
| 407 | return openmetrics.UNDERSCORES |
| 408 | return openmetrics.UNDERSCORES |
| 409 | |
| 410 | |
| 411 | def gzip_accepted(accept_encoding_header: str) -> bool: |