mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-09 03:44:23 +00:00
Add a BadRequest resource to help with BAD REQUEST
This commit is contained in:
parent
9682e68528
commit
059bb2250b
@ -21,7 +21,8 @@ from allmydata.util.encodingutil import to_bytes, quote_output
|
||||
|
||||
# Originally part of this module, so still part of its API:
|
||||
from .common_py3 import ( # noqa: F401
|
||||
get_arg, abbreviate_time, MultiFormatResource, WebError
|
||||
get_arg, abbreviate_time, MultiFormatResource, WebError,
|
||||
BadRequest,
|
||||
)
|
||||
|
||||
|
||||
|
@ -23,6 +23,15 @@ class WebError(Exception):
|
||||
self.code = code
|
||||
|
||||
|
||||
class BadRequest(resource.ErrorPage):
|
||||
"""
|
||||
``BadRequest`` is a specialiation of ``ErrorPage`` which returns the HTTP
|
||||
response code **BAD REQUEST**.
|
||||
"""
|
||||
def __init__(self, message=""):
|
||||
resource.ErrorPage.__init__(self, http.BAD_REQUEST, "Bad Request", message)
|
||||
|
||||
|
||||
def get_arg(ctx_or_req, argname, default=None, multiple=False):
|
||||
"""Extract an argument from either the query args (req.args) or the form
|
||||
body fields (req.fields). If multiple=False, this returns a single value
|
||||
|
Loading…
x
Reference in New Issue
Block a user