Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_whitenoise_file_response_has_only_one_header():
response = WhiteNoiseFileResponse(open(__file__, "rb"))
response.close()
headers = {key.lower() for key, value in response.items()}
# This subclass should have none of the default headers that FileReponse
# sets
assert headers == {"content-type"}
def serve(static_file, request):
response = static_file.get_response(request.method, request.META)
status = int(response.status)
http_response = WhiteNoiseFileResponse(response.file or (), status=status)
# Remove default content-type
del http_response["content-type"]
for key, value in response.headers:
http_response[key] = value
return http_response