CaseInsensitiveDict does not implement .get() yet

This commit is contained in:
jesopo 2019-09-10 15:59:54 +01:00
parent 6b17c64b15
commit 49527495b8

View file

@ -76,14 +76,14 @@ class Handler(http.server.BaseHTTPRequestHandler):
return _bot.get_setting("rest-api-minify", False)
def url_for(self, headers, route, endpoint, get_params={}):
hostname = headers.get("Host", None)
if not hostname:
return None
else:
if "Host" in headers:
host = headers["Host"]
get_params_str = ""
if get_params:
get_params = "?%s" % urllib.parse.urlencode(get_params)
return "%s/%s/%s%s" % (hostname, route, endpoint, get_params_str)
return "%s/%s/%s%s" % (host, route, endpoint, get_params_str)
else:
return None
def _url_for(self, headers):
return lambda route, endpoint, get_params={}: self.url_for(
headers, route, endpoint, get_params)