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)
| 557 | return values |
| 558 | |
| 559 | def decode_argument(self, value: bytes, name: Optional[str] = None) -> str: |
| 560 | """Decodes an argument from the request. |
| 561 | |
| 562 | The argument has been percent-decoded and is now a byte string. |
| 563 | By default, this method decodes the argument as utf-8 and returns |
| 564 | a unicode string, but this may be overridden in subclasses. |
| 565 | |
| 566 | This method is used as a filter for both `get_argument()` and for |
| 567 | values extracted from the url and passed to `get()`/`post()`/etc. |
| 568 | |
| 569 | The name of the argument is provided if known, but may be None |
| 570 | (e.g. for unnamed groups in the url regex). |
| 571 | """ |
| 572 | try: |
| 573 | return _unicode(value) |
| 574 | except UnicodeDecodeError: |
| 575 | raise HTTPError( |
| 576 | 400, "Invalid unicode in %s: %r" % (name or "url", value[:40]) |
| 577 | ) |
| 578 | |
| 579 | @property |
| 580 | def cookies(self) -> Dict[str, http.cookies.Morsel]: |
no test coverage detected