c# - Pumping Bytes Directly into Response.OutputStream - how to deal with byte count? -


i have need transfer large streams of data web service. rather increase iis buffer size in metabase, i'd pump bytes directly unbuffered response.outputstream.

response.clearheaders(); response.clear(); response.contenttype = "text/xml"; response.buffer = false; int len = getreport(protocolname, sourcename, reportname, pageindex, pagesize, response.outputstream); response.end(); 

this works fine, can know how many bytes have been retrieved after retrieving them, can't set contentlength header. following line throws exception (can't add headers after start returning content):

int len = getreport(protocolname, sourcename, reportname, pageindex, pagesize, response.outputstream); response.addheader("content-length", len.tostring()); // can't 

question: guess there aren't many options. suppose way handle introduce intermediate stream, e.g., memory stream, length of stream, set header, , pump that stream response.output stream. other ideas?'

content-length not required. if legitimately don't know prior sending content response stream, leave out. browser still display result fine, not able provide progress bar or percentage completion. if content small, not major concern.

http://www.w3.org/protocols/rfc2616/rfc2616-sec14.html#sec14.13

in http, should sent whenever message's length can determined prior being transferred

that's should , not must.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -