Buffered output from httpResponse.end ()?

In .NET, the description of httpResponse.end() reads: "Sends all current buffered output to the client." Can someone explain to me what this means? In particular, what is a "buffered output"? I ask because I was asked to replace httpResponse.end with HttpContext.Current.ApplicationInstance.CompleteRequest() . This causes problems when there are files, so I assume this phrase has something to do with it.

+4
source share
3 answers

Buffered output is the result that your program has already produced, but has not yet redirected to its destination.

Buffering is often used with I / O operations to avoid the cost of sending / writing data in small increments: instead of transferring output to the destination when writing, the system collects large chunks in a memory area called a โ€œbufferโ€ and sends / writes data only when reaching a certain size.

There are two ways in which buffered data is delivered to its destination:

  • The output volume reaches a certain threshold, or
  • You call some method to explicitly "flush" the buffer.

httpResponse.end is one such method: it empties the buffer by sending everything you wrote so far to the client.

+1
source

Instead of sending every bit of information as soon as you write it to the output stream, it stores what you wrote in memory until it receives โ€œsufficientโ€ data, which, in his opinion, takes time, to send to his client. The size of the buffer can vary greatly depending on the context and the reason for buffering the data. To "flush" the buffer, it is necessary to process all the pending data in the buffer (in this case, the processing tool sends it over the network to the client). What end does in your case.

Buffering can be performed for many reasons, but this is usually a matter of performance. It would be very wasteful and time consuming if you sent a network packet for each character that you wrote to your stream, or (in many cases) every line passed to Write . The application will execute faster by sending fewer and more packets of information.

+2
source

Buffered output means any output that is ready to be sent to the client but not yet sent to the client.

+1
source

All Articles