Fix nginx for pdf

This commit is contained in:
cuom1999 2022-08-31 10:28:54 -05:00
parent 7f3e22e3bf
commit 66b9240fd4

View file

@ -408,10 +408,8 @@ class ProblemPdfDescriptionView(ProblemMixin, SingleObjectMixin, View):
if not problem.pdf_description: if not problem.pdf_description:
raise Http404() raise Http404()
response = HttpResponse() response = HttpResponse()
if hasattr(settings, "DMOJ_PDF_PROBLEM_INTERNAL") and request.META.get( if request.META.get("SERVER_SOFTWARE", "").startswith("nginx/"):
"SERVER_SOFTWARE", "" response["X-Accel-Redirect"] = problem.pdf_description
).startswith("nginx/"):
response["X-Accel-Redirect"] = problem.pdf_description.path
else: else:
with open(problem.pdf_description.path, "rb") as f: with open(problem.pdf_description.path, "rb") as f:
response.content = f.read() response.content = f.read()