TUN-3838: ResponseWriter no longer reads and origin error tests

This commit is contained in:
Sudarsan Reddy
2021-02-11 14:36:42 +00:00
committed by Nuno Diegues
parent ab4dda5427
commit e20c4f8752
3 changed files with 300 additions and 209 deletions

View File

@@ -177,11 +177,28 @@ func (p *proxy) proxyStreamRequest(
originConn.Close()
}()
originConn.Stream(serveCtx, w, p.log)
eyeballStream := &bidirectionalStream{
writer: w,
reader: req.Body,
}
originConn.Stream(serveCtx, eyeballStream, p.log)
p.logOriginResponse(resp, fields)
return nil
}
type bidirectionalStream struct {
reader io.Reader
writer io.Writer
}
func (wr *bidirectionalStream) Read(p []byte) (n int, err error) {
return wr.reader.Read(p)
}
func (wr *bidirectionalStream) Write(p []byte) (n int, err error) {
return wr.writer.Write(p)
}
func (p *proxy) writeEventStream(w connection.ResponseWriter, respBody io.ReadCloser) {
reader := bufio.NewReader(respBody)
for {