Skip to content

Commit

Permalink
Revert "Check flusher interface before calling Flush (#479)"
Browse files Browse the repository at this point in the history
This reverts commit cf7d15a.
This introduced a recursive call to `Flush` in the proxy, which
will crash the application.
  • Loading branch information
johanbrandhorst committed Aug 6, 2019
1 parent 596ae17 commit f1950ed
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions go/grpcweb/grpc_web_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,10 @@ func (w *grpcWebResponse) WriteHeader(code int) {
}

func (w *grpcWebResponse) Flush() {
f, ok := w.wrapped.(http.Flusher)
if !ok {
return
}

if w.wroteHeaders || w.wroteBody {
// Work around the fact that WriteHeader and a call to Flush would have caused a 200 response.
// This is the case when there is no payload.
f.Flush()
w.wrapped.(http.Flusher).Flush()
}
}

Expand Down Expand Up @@ -95,7 +90,7 @@ func (w *grpcWebResponse) finishRequest(req *http.Request) {
w.copyTrailersToPayload()
} else {
w.WriteHeader(http.StatusOK)
w.Flush()
w.wrapped.(http.Flusher).Flush()
}
}

Expand All @@ -107,7 +102,7 @@ func (w *grpcWebResponse) copyTrailersToPayload() {
binary.BigEndian.PutUint32(trailerGrpcDataHeader[1:5], uint32(trailerBuffer.Len()))
w.wrapped.Write(trailerGrpcDataHeader)
w.wrapped.Write(trailerBuffer.Bytes())
w.Flush()
w.wrapped.(http.Flusher).Flush()
}

func extractTrailingHeaders(src http.Header, flushed http.Header) http.Header {
Expand Down Expand Up @@ -162,5 +157,5 @@ func (w *base64ResponseWriter) Flush() {
grpclog.Errorf("ignoring error Flushing base64 encoder: %v", err)
}
w.newEncoder()
w.Flush()
w.wrapped.(http.Flusher).Flush()
}

0 comments on commit f1950ed

Please sign in to comment.