diff options
author | Tomasz Kramkowski <tomasz@kramkow.ski> | 2023-03-27 19:12:40 +0100 |
---|---|---|
committer | Tomasz Kramkowski <tomasz@kramkow.ski> | 2023-03-27 19:12:40 +0100 |
commit | 5af2720086adc5337150259c7a6a37ade3770344 (patch) | |
tree | 7204f99aa270c531a78909783ec0f31d811ae7c6 | |
parent | 9d893cb55ecdad2d2c4aa5ff9262b16e4f4caec2 (diff) | |
download | paste-5af2720086adc5337150259c7a6a37ade3770344.tar.gz paste-5af2720086adc5337150259c7a6a37ade3770344.tar.xz paste-5af2720086adc5337150259c7a6a37ade3770344.zip |
Remove redirect functionality
-rw-r--r-- | paste/__init__.py | 25 | ||||
-rw-r--r-- | 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(?)""", |