internal/tun2: relay stream body with closer
This commit is contained in:
parent
c2fbaa9da9
commit
9bb2d4f436
|
@ -2,10 +2,8 @@ package tun2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
|
||||||
"context"
|
"context"
|
||||||
"expvar"
|
"expvar"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
@ -143,15 +141,6 @@ func (c *Connection) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, ErrCantReadResponse.Error())
|
return nil, errors.Wrap(err, ErrCantReadResponse.Error())
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "can't read response body")
|
|
||||||
}
|
|
||||||
|
|
||||||
resp.Body = ioutil.NopCloser(bytes.NewBuffer(body))
|
|
||||||
resp.ContentLength = int64(len(body))
|
|
||||||
|
|
||||||
c.counter.Add(1)
|
c.counter.Add(1)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue