X-Git-Url: https://git.distorted.org.uk/~mdw/chopwood/blobdiff_plain/76ee7d4f64bc1f20013f44c8045cd708ef0b9641..9e574017f801c1bb4b5d4856e988b892d90246a2:/cgi.py diff --git a/cgi.py b/cgi.py index 6006062..cfa26f7 100644 --- a/cgi.py +++ b/cgi.py @@ -453,6 +453,11 @@ class Subcommand (SC.Subcommand): CGI parameters. """ + def __init__(me, name, contexts, desc, func, + methods = ['GET', 'POST'], *args, **kw): + super(Subcommand, me).__init__(name, contexts, desc, func, *args, **kw) + me.methods = set(methods) + def cgi(me, param, path): """ Invoke the subcommand given a collection of CGI parameters. @@ -484,6 +489,12 @@ class Subcommand (SC.Subcommand): want = {} kw = {} + ## Check the request method against the permitted list. + meth = METHOD + if meth == 'HEAD': meth = 'GET' + if meth not in me.methods: + raise U.ExpectedError, (500, "Unexpected request method `%s'" % METHOD) + def set_value(k, v): """Set a simple value: we shouldn't see multiple values.""" if k in kw: