From 5af2720086adc5337150259c7a6a37ade3770344 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Mon, 27 Mar 2023 19:12:40 +0100 Subject: Remove redirect functionality --- paste/__init__.py | 25 +------------------------ paste/store.py | 7 +------ 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/paste/__init__.py b/paste/__init__.py index f22b5d7..3ee4468 100644 --- a/paste/__init__.py +++ b/paste/__init__.py @@ -54,25 +54,6 @@ def simple_response( return [body] -def redirect(start_response: StartResponse, location: bytes, typ: str) -> Response: - status = { - "text/x.redirect.301": "301 Moved Permanently", - "text/x.redirect.302": "302 Found", - }.get(typ) - if not status: - return simple_response(start_response, "500 Internal Server Error") - body = location - start_response( - status, - [ - ("Location", location.decode()), - ("Content-Type", "text/plain"), - ("Content-Length", str(len(body))), - ], - ) - return [body] - - ProtoMiddleware = Callable[[App, Env, StartResponse], Response] Middleware = Callable[[App], App] @@ -222,8 +203,6 @@ def application(environ: Env, start_response: StartResponse) -> Response: if not row: return simple_response(start_response, "404 Not Found") content_type, content_hash, content = row - if content_type.startswith("text/x.redirect"): - return redirect(start_response, content, content_type) start_response( "200 OK", [ @@ -237,9 +216,7 @@ def application(environ: Env, start_response: StartResponse) -> Response: row = store.head(conn, name) if not row: return simple_response(start_response, "404 Not Found") - content_type, content_hash, content_length, opt_content = row - if content_type.startswith("text/x.redirect"): - return redirect(start_response, opt_content, content_type) + content_type, content_hash, content_length = row start_response( "200 OK", [ diff --git a/paste/store.py b/paste/store.py index ec51a7f..ed81560 100644 --- a/paste/store.py +++ b/paste/store.py @@ -38,12 +38,7 @@ def get(conn: Connection, name: str): def head(conn: Connection, name: str): row = conn.execute( - """SELECT link.content_type, file.hash, length(file.content), - CASE - WHEN link.content_type LIKE 'text/x.redirect%' - THEN file.content - ELSE NULL - END + """SELECT link.content_type, file.hash, length(file.content) FROM link JOIN file ON file.hash = link.file_hash WHERE name_hash = DATA_HASH(?)""", -- cgit v1.2.3-54-g00ecf