From 15ad5b08c4c821fb8341f499990f98a2e7b39fb4 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Sun, 18 Aug 2019 11:59:02 +0200 Subject: [PATCH] Tweak media proxying --- app.py | 5 +++-- utils/template_filters.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index 9ed4622..25c2d56 100644 --- a/app.py +++ b/app.py @@ -236,8 +236,9 @@ def microblogpub_jsonld(): ) -@app.route("/p/") -def proxy(url: str) -> Any: +@app.route("/p//") +def proxy(scheme: str, url: str) -> Any: + url = f"{scheme}://{url}" req_headers = { k: v for k, v in dict(request.headers).items() diff --git a/utils/template_filters.py b/utils/template_filters.py index 7c61d49..72d2c71 100644 --- a/utils/template_filters.py +++ b/utils/template_filters.py @@ -248,11 +248,11 @@ def _get_file_url(url, size, kind) -> str: _FILE_URL_CACHE[k] = out return out - # MEDIA_CACHE.cache(url, kind) _logger.error(f"cache not available for {url}/{size}/{kind}") if url.startswith(BASE_URL): return url - return f"/p/{url}" + p = urlparse(url) + return f"/p/{p.scheme}" + p._replace(scheme="").geturl()[1:] @filters.app_template_filter()