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)
| 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]: |
no test coverage detected