MCPcopy
hub / github.com/tornadoweb/tornado / decode_argument

Method decode_argument

tornado/web.py:610–628  ·  view source on GitHub ↗

Decodes an argument from the request. The argument has been percent-decoded and is now a byte string. By default, this method decodes the argument as utf-8 and returns a unicode string, but this may be overridden in subclasses. This method is used as a filter for bo

(self, value: bytes, name: Optional[str] = None)

Source from the content-addressed store, hash-verified

608 return values
609
610 def decode_argument(self, value: bytes, name: Optional[str] = None) -> str:
611 """Decodes an argument from the request.
612
613 The argument has been percent-decoded and is now a byte string.
614 By default, this method decodes the argument as utf-8 and returns
615 a unicode string, but this may be overridden in subclasses.
616
617 This method is used as a filter for both `get_argument()` and for
618 values extracted from the url and passed to `get()`/`post()`/etc.
619
620 The name of the argument is provided if known, but may be None
621 (e.g. for unnamed groups in the url regex).
622 """
623 try:
624 return _unicode(value)
625 except UnicodeDecodeError:
626 raise HTTPError(
627 400, "Invalid unicode in {}: {!r}".format(name or "url", value[:40])
628 )
629
630 @property
631 def cookies(self) -> Dict[str, http.cookies.Morsel]:

Callers 2

_get_argumentsMethod · 0.95
_executeMethod · 0.95

Calls 2

HTTPErrorClass · 0.85
formatMethod · 0.80

Tested by

no test coverage detected