@ -3,6 +3,7 @@ package proxy
import (
"encoding/json"
"errors"
"io"
"net/http"
"net/url"
@ -96,6 +97,7 @@ type Response struct {
StatusCode int `json:"statusCode"`
Header http.Header `json:"header"`
Body []byte `json:"-"`
BodyReader io.Reader
decodedBody []byte
decoded bool // decoded reports whether the response was sent compressed but was decoded to decodedBody.
@ -131,13 +131,22 @@ func (proxy *Proxy) ServeHTTP(res http.ResponseWriter, req *http.Request) {
if err != nil {
logErr(log, err)
}
} else if response.Body != nil && len(response.Body) > 0 {
if response.Body != nil {
if response.BodyReader != nil {
_, err := io.Copy(res, response.BodyReader)
if len(response.Body) > 0 {
_, err := res.Write(response.Body)
// when addons panic
defer func() {