[Fizz] Always call flush() if it exists (#21625)
This commit is contained in:
parent
46926993fc
commit
cc4d24ab0b
|
@ -11,8 +11,6 @@ import type {Writable} from 'stream';
|
||||||
|
|
||||||
type MightBeFlushable = {
|
type MightBeFlushable = {
|
||||||
flush?: () => void,
|
flush?: () => void,
|
||||||
// Legacy
|
|
||||||
flushHeaders?: () => void,
|
|
||||||
...
|
...
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31,14 +29,11 @@ export function flushBuffered(destination: Destination) {
|
||||||
// If we don't have any more data to send right now.
|
// If we don't have any more data to send right now.
|
||||||
// Flush whatever is in the buffer to the wire.
|
// Flush whatever is in the buffer to the wire.
|
||||||
if (typeof destination.flush === 'function') {
|
if (typeof destination.flush === 'function') {
|
||||||
// http.createServer response have flush(), but it has a different meaning and
|
|
||||||
// is deprecated in favor of flushHeaders(). Detect to avoid a warning.
|
|
||||||
if (typeof destination.flushHeaders !== 'function') {
|
|
||||||
// By convention the Zlib streams provide a flush function for this purpose.
|
// By convention the Zlib streams provide a flush function for this purpose.
|
||||||
|
// For Express, compression middleware adds this method.
|
||||||
destination.flush();
|
destination.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export function beginWriting(destination: Destination) {
|
export function beginWriting(destination: Destination) {
|
||||||
// Older Node streams like http.createServer don't have this.
|
// Older Node streams like http.createServer don't have this.
|
||||||
|
|
Loading…
Reference in New Issue