Revert "tun2: put content length in response"
This reverts commit c3b786b992
.
This commit is contained in:
parent
8e94968e17
commit
d257215ff4
|
@ -2,10 +2,11 @@ package tun2
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/Xe/ln"
|
||||
|
@ -126,6 +127,7 @@ func (c *Connection) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||
if err != nil {
|
||||
return nil, errors.Wrap(err, ErrCantOpenSessionStream.Error())
|
||||
}
|
||||
defer stream.Close()
|
||||
|
||||
err = req.Write(stream)
|
||||
if err != nil {
|
||||
|
@ -140,13 +142,13 @@ func (c *Connection) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
cl := resp.Header.Get("Content-Length")
|
||||
asInt, err := strconv.Atoi(cl)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "can't read response body")
|
||||
}
|
||||
|
||||
resp.ContentLength = int64(asInt)
|
||||
resp.Body = ioutil.NopCloser(bytes.NewBuffer(body))
|
||||
resp.ContentLength = int64(len(body))
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue