1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-08-01 18:18:31 +00:00

Web: add support for the POST HTTP method. (#1097)

* Web: add support for the POST HTTP method.

This patch adds support for POST in addition to the already supported GET.

This is needed for implementing more complex web modules that also
support configuration modifications and advanced queries.

* Base web: return METHOD_NOT_ALLOWED when method isn't implemenetd.

Co-authored-by: Unrud <Unrud@users.noreply.github.com>
This commit is contained in:
Tom Hacohen 2020-09-14 19:17:45 +03:00 committed by GitHub
parent 6091bd46a3
commit d3bb19800c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 58 additions and 3 deletions

View file

@ -104,6 +104,11 @@ class BaseTest:
self._check_status(status, 200, check)
return status, answer
def post(self, path, check=True, **args):
status, _, answer = self.request("POST", path, **args)
self._check_status(status, 200, check)
return status, answer
def put(self, path, data, check=True, **args):
status, _, answer = self.request("PUT", path, data, **args)
self._check_status(status, 201, check)

View file

@ -27,3 +27,6 @@ from radicale import web
class Web(web.BaseWeb):
def get(self, environ, base_prefix, path, user):
return client.OK, {"Content-Type": "text/plain"}, "custom"
def post(self, environ, base_prefix, path, user):
return client.OK, {"Content-Type": "text/plain"}, "custom post"

View file

@ -63,3 +63,6 @@ class TestBaseWebRequests(BaseTest):
self.application = Application(self.configuration)
_, answer = self.get("/.web")
assert answer == "custom"
_, answer = self.post("/.web")
assert answer == "custom post"