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 (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Xe/ln"
|
"github.com/Xe/ln"
|
||||||
|
@ -126,6 +127,7 @@ func (c *Connection) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, ErrCantOpenSessionStream.Error())
|
return nil, errors.Wrap(err, ErrCantOpenSessionStream.Error())
|
||||||
}
|
}
|
||||||
|
defer stream.Close()
|
||||||
|
|
||||||
err = req.Write(stream)
|
err = req.Write(stream)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -140,13 +142,13 @@ func (c *Connection) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
cl := resp.Header.Get("Content-Length")
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
asInt, err := strconv.Atoi(cl)
|
|
||||||
if err != nil {
|
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
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue