support http-100 continue for sniffer
This commit is contained in:
@@ -470,12 +470,23 @@ func (h *Sniffer) httpRoundTrip(ctx context.Context, rw, cc io.ReadWriter, node
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
xio.SetReadDeadline(cc, time.Now().Add(h.ReadTimeout))
|
br := bufio.NewReader(cc)
|
||||||
resp, err := http.ReadResponse(bufio.NewReader(cc), req)
|
var resp *http.Response
|
||||||
if err != nil {
|
for {
|
||||||
log.Errorf("read response: %v", err)
|
xio.SetReadDeadline(cc, time.Now().Add(h.ReadTimeout))
|
||||||
res.Write(rw)
|
resp, err = http.ReadResponse(br, req)
|
||||||
return
|
if err != nil {
|
||||||
|
log.Errorf("read response: %v", err)
|
||||||
|
res.Write(rw)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if resp.StatusCode >= http.StatusContinue && resp.StatusCode < http.StatusOK {
|
||||||
|
resp.Write(rw)
|
||||||
|
resp.Body.Close()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
xio.SetReadDeadline(cc, time.Time{})
|
xio.SetReadDeadline(cc, time.Time{})
|
||||||
|
|||||||
@@ -337,11 +337,22 @@ func (h *Sniffer) httpRoundTrip(ctx context.Context, rw, cc io.ReadWriter, req *
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
xio.SetReadDeadline(cc, time.Now().Add(h.ReadTimeout))
|
br := bufio.NewReader(cc)
|
||||||
resp, err := http.ReadResponse(bufio.NewReader(cc), req)
|
var resp *http.Response
|
||||||
if err != nil {
|
for {
|
||||||
err = fmt.Errorf("read response: %w", err)
|
xio.SetReadDeadline(cc, time.Now().Add(h.ReadTimeout))
|
||||||
return
|
resp, err = http.ReadResponse(br, req)
|
||||||
|
if err != nil {
|
||||||
|
err = fmt.Errorf("read response: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if resp.StatusCode >= http.StatusContinue && resp.StatusCode < http.StatusOK {
|
||||||
|
resp.Write(rw)
|
||||||
|
resp.Body.Close()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
xio.SetReadDeadline(cc, time.Time{})
|
xio.SetReadDeadline(cc, time.Time{})
|
||||||
|
|||||||
Reference in New Issue
Block a user