fix: stabilize generated ZIP download for large archives
Avoid HTTP/2 streaming failures on large archive downloads by returning the stored ZIP as a buffered HttpResponse with explicit Content-Length. Also update archive download tests to support both buffered and streaming response objects. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -351,7 +351,7 @@ class WorkOrderImagesEndpointTests(TestCase):
|
||||
download_response = self.client.get(f"/api/fleet/reports/generated-archives/{generated.pk}/download/")
|
||||
self.assertEqual(download_response.status_code, 200)
|
||||
self.assertEqual(download_response['Content-Type'], 'application/zip')
|
||||
archive_bytes = b''.join(download_response.streaming_content)
|
||||
archive_bytes = download_response.content if hasattr(download_response, 'content') else b''.join(download_response.streaming_content)
|
||||
|
||||
archive = zipfile.ZipFile(BytesIO(archive_bytes))
|
||||
self.assertIn('MT150726.SN-Test_servisni_zadatak.docx', archive.namelist())
|
||||
@@ -392,7 +392,7 @@ class WorkOrderImagesEndpointTests(TestCase):
|
||||
download_response = self.client.get(f"/api/fleet/reports/generated-archives/{generated.pk}/download/")
|
||||
self.assertEqual(download_response.status_code, 200)
|
||||
self.assertEqual(download_response['Content-Type'], 'application/zip')
|
||||
archive_bytes = b''.join(download_response.streaming_content)
|
||||
archive_bytes = download_response.content if hasattr(download_response, 'content') else b''.join(download_response.streaming_content)
|
||||
|
||||
archive = zipfile.ZipFile(BytesIO(archive_bytes))
|
||||
names = archive.namelist()
|
||||
|
||||
Reference in New Issue
Block a user