Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static files aren't sending the file size, causing the browser to not display the file download progress #742

Open
MrPowerGamerBR opened this issue Jan 6, 2017 · 3 comments

Comments

@MrPowerGamerBR
Copy link

http://i.imgur.com/Zlx35tA.png

This is what happens when trying to download a static file hosted on Sparkjava (by using Spark.externalStaticFileLocation(rootFolder + "static");)

I'm not a 100% Java/HTML/header magic expert, but I think it doesn't show the file progress because the file size header isn't sent, right?

@jakaarl
Copy link
Contributor

jakaarl commented Jan 17, 2017

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.

@jakaarl
Copy link
Contributor

jakaarl commented May 8, 2017

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.

@jakaarl
Copy link
Contributor

jakaarl commented May 8, 2017

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.

lepe pushed a commit to Intellisrc/spark that referenced this issue Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants