diff options
Diffstat (limited to 'paste')
-rw-r--r-- | paste/__init__.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/paste/__init__.py b/paste/__init__.py index 2ec00a4..c769997 100644 --- a/paste/__init__.py +++ b/paste/__init__.py @@ -36,7 +36,10 @@ DB_PATH = "paste.sqlite3" def simple_response( - start_response: StartResponse, status: str, exc_info: Optional[tuple] = None + start_response: StartResponse, + status: str, + extra_headers: list = list(), + exc_info: Optional[tuple] = None, ) -> Response: body = (status + "\n").encode() start_response( @@ -44,6 +47,7 @@ def simple_response( [ ("Content-Type", "text/plain"), ("Content-Length", str(len(body))), + *extra_headers, ], exc_info, ) @@ -197,7 +201,11 @@ def authenticate(app: App, environ: Env, start_response: StartResponse) -> Respo if environ["REQUEST_METHOD"] in {"GET", "HEAD"} or check_auth(): return app(environ, start_response) - return simple_response(start_response, "401 Unauthorized") + return simple_response( + start_response, + "401 Unauthorized", + extra_headers=[("WWW-Authenticate", "APIKey")], + ) @catch_exceptions |