From 48704d9865d429fe2c6a4d54e76b948163a43644 Mon Sep 17 00:00:00 2001 From: Lane Jennison Date: Sat, 4 Dec 2021 20:58:26 -0500 Subject: [PATCH] pass scheme to get_redirect function instead of checking request object --- app/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/main.py b/app/main.py index f332263..5a992ed 100644 --- a/app/main.py +++ b/app/main.py @@ -83,7 +83,7 @@ def get_region(client_ip, reader=geolite_reader, continents=mirror.continents): else: return None -def get_redirect(path, client_ip, mirror_class=mirror, dl_map=DL_MAP): +def get_redirect(path, client_ip, scheme, mirror_class=mirror, dl_map=DL_MAP): """ get redirect based on path and IP """ region = get_region(client_ip) split_path = path.split('/') @@ -98,7 +98,7 @@ def get_redirect(path, client_ip, mirror_class=mirror, dl_map=DL_MAP): allow schemes from 3 (ftp) to 5 (https) character length """ mirror_url = mirror_class.next(region) if mirror_url.find('://', 3, 8) == -1: - mirror_url = get_scheme() + '://' + mirror_url + mirror_url = scheme + '://' + mirror_url if mirror_class.mode == "dl_map" and len(split_path) == 2: key = "{}/{}".format(split_path[0], split_path[1]) @@ -163,7 +163,7 @@ def show_geoip(reader=geolite_reader): @app.route('/') def catch_all(path): """ default app route for redirect """ - resp = redirect(get_redirect(path, get_ip()), 302) + resp = redirect(get_redirect(path, get_ip(), get_scheme()), 302) resp.headers['X-Request-Scheme'] = get_scheme() return resp