Skip 0 byte stream writes (#10875)

Don't send a packet when receiving 0 bytes or there is an error recorded
This commit is contained in:
Klaus Post 2020-11-11 18:07:40 -08:00 committed by GitHub
parent aa158228f9
commit 1c3590078d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -781,6 +781,10 @@ type httpStreamResponse struct {
// Write part of the the streaming response.
// Note that upstream errors are currently not forwarded, but may be in the future.
func (h *httpStreamResponse) Write(b []byte) (int, error) {
if len(b) == 0 || h.err != nil {
// Ignore 0 length blocks
return 0, h.err
}
tmp := make([]byte, len(b))
copy(tmp, b)
h.block <- tmp