From: Michael Tremer Date: Thu, 26 May 2022 11:57:15 +0000 (+0000) Subject: hub: Add support for POST requests X-Git-Tag: 0.9.28~748 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a577fa0b4a095e6bd1bf92a235e4cfe764a31b8;p=pakfire.git hub: Add support for POST requests Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/hub.py b/src/pakfire/hub.py index e47a1db88..cccd532a5 100644 --- a/src/pakfire/hub.py +++ b/src/pakfire/hub.py @@ -52,17 +52,25 @@ class Hub(object): # XXX support proxies - async def _request(self, method, path, body_producer=None, **kwargs): + async def _request(self, method, path, body=None, body_producer=None, **kwargs): # Make absolute URL url = urllib.parse.urljoin(self.url, path) + # Convert any query arguments + query_args = urllib.parse.urlencode(kwargs) + # Add query arguments if method in ("GET", "PUT"): - url = "%s?%s" % (url, urllib.parse.urlencode(kwargs)) + url = "%s?%s" % (url, query_args) + + # Add any arguments to the body + elif method == "POST": + if body is None: + body = query_args # Make the request req = tornado.httpclient.HTTPRequest( - method=method, url=url, + method=method, url=url, body=body, # Authentication auth_username=self.username, auth_password=self.password,