MCPcopy
hub / github.com/benoitc/gunicorn / _is_valid_token

Method _is_valid_token

gunicorn/asgi/parser.py:812–822  ·  view source on GitHub ↗

Check if data contains only RFC 9110 token characters.

(self, data)

Source from the content-addressed store, hash-verified

810 return self._is_valid_token(method)
811
812 def _is_valid_token(self, data):
813 """Check if data contains only RFC 9110 token characters."""
814 if not data:
815 return False
816 for c in data:
817 if c < 0x21 or c > 0x7e:
818 return False
819 # RFC 9110 delimiters: "(),/:;<=>?@[\]{}
820 if c in b'"(),/:;<=>?@[\\]{}"':
821 return False
822 return True
823
824 def _has_invalid_header_chars(self, value):
825 """RFC 9110 section 5.5: only VCHAR, SP, HTAB, and obs-text allowed."""

Callers 2

_parse_headersMethod · 0.95
_is_valid_methodMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected