Skip to content

Commit 6526b61

Browse files
committed
fix: remove delay when using csv export actions.
The CSV file is written incrementally, so we can't determine the Content-Length. When using HTTP/1.1, this causes a delay while the browser waits for a timeout. Forcing the connection to close after the CSV file is written removes the delay. Ideally we should shift to chunked transfer encoding for these two actions, but that is much more invasive and when posting a request for CSV, it is unlikely that another request will be sent over the same socket.
1 parent db074fc commit 6526b61

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CHANGES.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ Fixed:
177177
- Cleanup tracker index generation by roundup-server. Send
178178
correct Content-Length headers so HTTP/1.1 connections don't
179179
hang. (John Rouillard)
180+
- Fix delay when using csv export actions. The CSV file is written
181+
incrementally, so we can't determine the Content-Length. When using
182+
HTTP/1.1, this causes a delay while the browser waits for a timeout.
183+
Forcing the connection to close after the CSV file is written
184+
removes the delay. (John Rouillard)
180185

181186
Features:
182187

roundup/cgi/actions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,6 +1724,11 @@ def fct(arg):
17241724
repr_function = represent[name]
17251725
row.append(repr_function(klass.get(itemid, name)))
17261726
self.client._socket_op(writer.writerow, row)
1727+
1728+
# force close of connection since we can't send a
1729+
# Content-Length header.
1730+
self.client.request.close_connection = True
1731+
17271732
return '\n'
17281733

17291734

@@ -1836,6 +1841,10 @@ def handle(self):
18361841
row.append(str(value))
18371842
self.client._socket_op(writer.writerow, row)
18381843

1844+
# force close of connection since we can't send a
1845+
# Content-Length header.
1846+
self.client.request.close_connection = True
1847+
18391848
return '\n'
18401849

18411850

0 commit comments

Comments
 (0)