Static files aren't sending the file size, causing the browser to not display the file download progress
MrPowerGamerBR opened this issue · comments
Took a quick look. This isn't quite as trivial as it first seemed, due to the possibility of gzipped content. Will look more closely into this.
I think a workable solution would be something to the effect of this: wrap the response stream with a wrapper which keeps track of written bytes correctly whether or not there is a gzipped stream in between or not, and add the content length header after done.
Did some experimentation. The approach does somewhat work, but there's a big problem with setting the length header and flushing the stream - if the "final flush" is left last, content length doesn't reflect possible unflushed bytes, but if flushing is done first, it commits the response and the header will not be set.
Catching the flush and setting the header before propagating the flush to the underlying servlet output stream should work.