elwig-backend: Add WWW-Authenticate header

This commit is contained in:
2024-09-17 11:43:45 +02:00
parent 9a139eccf9
commit 572a1fc51d

View File

@ -95,6 +95,8 @@ class ElwigApi(BaseHTTPRequestHandler):
self.send_header('Access-Control-Allow-Origin', '*') self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Access-Control-Allow-Headers', 'Authorization') self.send_header('Access-Control-Allow-Headers', 'Authorization')
self.send_header('Access-Control-Allow-Methods', 'HEAD, GET, OPTIONS') self.send_header('Access-Control-Allow-Methods', 'HEAD, GET, OPTIONS')
if status_code == 401:
self.send_header('WWW-Authenticate', 'Basic realm=Elwig')
if self.headers.get('Accept-Encoding') and len(data) > 64: if self.headers.get('Accept-Encoding') and len(data) > 64:
accept_encoding = [e.strip() for e in self.headers.get('Accept-Encoding').split(',')] accept_encoding = [e.strip() for e in self.headers.get('Accept-Encoding').split(',')]
if 'gzip' in accept_encoding: if 'gzip' in accept_encoding: