tun2: read entire response body
This commit is contained in:
parent
3fefd31625
commit
c2ac2e3055
|
@ -2,7 +2,9 @@ package tun2
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
|
@ -138,6 +140,15 @@ func (c *Connection) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||
if err != nil {
|
||||
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))
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue