Revert "tun2: connection: do things better"
This reverts commit 64524eefc1
. re
This commit is contained in:
parent
64524eefc1
commit
99d5acb880
|
@ -4,6 +4,7 @@ import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
@ -138,12 +139,20 @@ 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 = &mixedReadCloser{
|
resp.Body = &mixedReadCloser{
|
||||||
Reader: buf,
|
Reader: buf,
|
||||||
Closer: stream,
|
Closer: stream,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resp.ContentLength = int64(len(body))
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue