This is a great question. I want to know the answer, too.
For example, when I use FireFox to download the latest Ubuntu ISO image via HTTP (yes, I know this is abusive) the FireFox download manager knows exactly how many bytes it is expecting. And surely the data are being chunked for streaming. Could an HTTP guru explain this? Maybe I should fire up wireshark and capture some headers and response codes.
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/7FlhyAezwwcJ.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

Hello,I am using the Java API and have been facing the same problem as you:- I have an InputStream- I know the total length of data that will be streamed- I wanted the size of the downloaded file to be displayed in the web client (so that a progress bar is displayed)- I don't know much of Scala ;-)Here is how I made it to work:1) I created a Java Helper class containing the following methods:public class DownloadFileHelper {String fileId;public DownloadFileHelper(String fid) {this.fileId = fid;}public int getContentLength() {// retrieve the length of the requested file (via DB query or any other mean that suit your needs)}public InputStream getInputStream() {//Build an input stream that will be send us the content of requested file}}2) I created a really simple Controller in Scala that uses this helperpackage controllersimport play.api._import play.api.mvc._import java.io.InputStreamimport controllers.worker.DownloadFileHelperimport play.api.libs.iteratee.Enumerator/*** Implements fileDownload in Scala because the withHeaders method is* not available in the current version of the Java API (and content-length* cannot be set).** This property is required to allow web browsers to display a progress bar* during file download.**/object FilesDownload extends Controller{def downloadFile(fileId:String) = Action {//All the backend calls are inside the worker threads to keep scala part as simple as possibleval worker:DownloadFileHelpder = new DownloadFileHelper(fileId);val is:InputStream = worker.getInputStream();var length = ""+worker.getContentLength();Ok.stream(Enumerator.fromStream(is)).withHeaders(CONTENT_LENGTH -> length);}}3) Say hello to the progress bar in your browser ;-)Hope it helps!Regards,David