Vote count:
0
TL;DR: How can I transfer large files with a known size using WCF, and still show progress to the final user?
I have a WCF REST service which downloads and then serves very large files (1-20Gb). To simplify, think of it as a proxy. This obliges me to set TransferMode = Streamed or TransferMode = StreamedResponse on the Binding, or the end client will have to wait for the source files to be downloaded to the webserver before the actual download begins. Also, buffered transfer mode kills the server for large files (RAM usage). Intermediate disk storage is not an option. From TransferMode man page:
(...) Buffered transfers hold the entire message in a memory buffer until the transfer is complete.
But when setting TransferMode to Streamed or StreamedResponse, WCF no longer returns the header Content-length to the client. This is consistent with wikipedias article on chunked transfer:
(...) uses the Transfer-Encoding HTTP header in place of the Content-Length header (...)
But I always know the size of the data to be transferred beforehand, and for the end user, it's very frustrating not to know the size of the download. So:
(How) can I configure the WCF binding to use a "streaming" Transfer mode (more specifically, not buffering the entire message before sending) and still use the Content-Length header? This q/a states that the http standard disallows both Transfer-Encoding and Content-length: 123456 in the same message, so I guess that's not an option? I have tried modifying the headers using an inspector in IDispatchMessage.BeforeSendReply but at this point the Content-Length header has not yet been removed, and Transfer-Encoding has not yet been set, so it's "too early".
Aucun commentaire:
Enregistrer un commentaire