-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Description
by trevor.strohman:
http.ReverseProxy buffers writes (because of NewReadWriter in http/server.go). This can break server-push applications where the client is expected to read pieces of the response as they arrive. Currently ReverseProxy.ServeHTTP does this: if res.Body != nil { io.Copy(rw, res.Body) } the buffering is built into the rw. To add flushing you'd need something like: for { nr, err := res.Body.Read(buf) if err != nil { return err } rw.Write(buf[0:nr]) rw.(http.Flusher).Flush() } Brad remarks that buffering is usually good so this hurts the common case, and perhaps this should be an parameter setting, or perhaps the Copy function itself could be a parameter.