Setting Content-Length header for responses too big to buffer

V

Vlad Hrybok

Hi, all.

I am writing an http handler that sends out lots of large files using
HttpResponse. I found that the only way to set Content-Length header on the
response is to allow the response to get completely buffered, which is
something I need to avoid because it wastes memory and delays data from being
sent. Setting response.Buffer = false; or doing response.Flush(); turns on
chunking and removes the Content-Length header altogether, so the requestor
loses the content length information and does not now how much data to expect.

How can I set the Content-Length header, and yet prevent complete buffering
of the response?

Thank you,
 
B

bruce barker

you just have to set the content header value before writing any body
content (before calling write).

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top