mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-09-27 12:07:59 +02:00
Add Content-Type: text/plain
header to custom transports' error responses
This commit is contained in:
@@ -93,7 +93,7 @@ func (t transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||||||
Proto: "HTTP/1.0",
|
Proto: "HTTP/1.0",
|
||||||
ProtoMajor: 1,
|
ProtoMajor: 1,
|
||||||
ProtoMinor: 0,
|
ProtoMinor: 0,
|
||||||
Header: http.Header{},
|
Header: http.Header{"Content-Type": {"text/plain"}},
|
||||||
ContentLength: int64(body.Len()),
|
ContentLength: int64(body.Len()),
|
||||||
Body: io.NopCloser(body),
|
Body: io.NopCloser(body),
|
||||||
Close: false,
|
Close: false,
|
||||||
@@ -138,7 +138,7 @@ func (t transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||||||
Proto: "HTTP/1.0",
|
Proto: "HTTP/1.0",
|
||||||
ProtoMajor: 1,
|
ProtoMajor: 1,
|
||||||
ProtoMinor: 0,
|
ProtoMinor: 0,
|
||||||
Header: header,
|
Header: http.Header{"Content-Type": {"text/plain"}},
|
||||||
ContentLength: int64(body.Len()),
|
ContentLength: int64(body.Len()),
|
||||||
Body: io.NopCloser(body),
|
Body: io.NopCloser(body),
|
||||||
Close: false,
|
Close: false,
|
||||||
|
@@ -122,7 +122,7 @@ func respNotFound(req *http.Request, msg string) *http.Response {
|
|||||||
Proto: "HTTP/1.0",
|
Proto: "HTTP/1.0",
|
||||||
ProtoMajor: 1,
|
ProtoMajor: 1,
|
||||||
ProtoMinor: 0,
|
ProtoMinor: 0,
|
||||||
Header: make(http.Header),
|
Header: http.Header{"Content-Type": {"text/plain"}},
|
||||||
ContentLength: int64(len(msg)),
|
ContentLength: int64(len(msg)),
|
||||||
Body: io.NopCloser(strings.NewReader(msg)),
|
Body: io.NopCloser(strings.NewReader(msg)),
|
||||||
Close: false,
|
Close: false,
|
||||||
|
@@ -88,7 +88,7 @@ func (t transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||||||
Proto: "HTTP/1.0",
|
Proto: "HTTP/1.0",
|
||||||
ProtoMajor: 1,
|
ProtoMajor: 1,
|
||||||
ProtoMinor: 0,
|
ProtoMinor: 0,
|
||||||
Header: http.Header{},
|
Header: http.Header{"Content-Type": {"text/plain"}},
|
||||||
ContentLength: int64(body.Len()),
|
ContentLength: int64(body.Len()),
|
||||||
Body: io.NopCloser(body),
|
Body: io.NopCloser(body),
|
||||||
Close: false,
|
Close: false,
|
||||||
@@ -196,7 +196,7 @@ func handleError(req *http.Request, err error) (*http.Response, error) {
|
|||||||
Proto: "HTTP/1.0",
|
Proto: "HTTP/1.0",
|
||||||
ProtoMajor: 1,
|
ProtoMajor: 1,
|
||||||
ProtoMinor: 0,
|
ProtoMinor: 0,
|
||||||
Header: make(http.Header),
|
Header: http.Header{"Content-Type": {"text/plain"}},
|
||||||
ContentLength: int64(len(err.Error())),
|
ContentLength: int64(len(err.Error())),
|
||||||
Body: io.NopCloser(strings.NewReader(err.Error())),
|
Body: io.NopCloser(strings.NewReader(err.Error())),
|
||||||
Close: false,
|
Close: false,
|
||||||
|
@@ -111,7 +111,7 @@ func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||||||
Proto: "HTTP/1.0",
|
Proto: "HTTP/1.0",
|
||||||
ProtoMajor: 1,
|
ProtoMajor: 1,
|
||||||
ProtoMinor: 0,
|
ProtoMinor: 0,
|
||||||
Header: http.Header{},
|
Header: http.Header{"Content-Type": {"text/plain"}},
|
||||||
ContentLength: int64(body.Len()),
|
ContentLength: int64(body.Len()),
|
||||||
Body: io.NopCloser(body),
|
Body: io.NopCloser(body),
|
||||||
Close: false,
|
Close: false,
|
||||||
@@ -318,16 +318,14 @@ func handleError(req *http.Request, err error) (*http.Response, error) {
|
|||||||
return nil, ierrors.Wrap(err, 0)
|
return nil, ierrors.Wrap(err, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
body := strings.NewReader(err.Error())
|
|
||||||
|
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: rerr.Response.StatusCode,
|
StatusCode: rerr.Response.StatusCode,
|
||||||
Proto: "HTTP/1.0",
|
Proto: "HTTP/1.0",
|
||||||
ProtoMajor: 1,
|
ProtoMajor: 1,
|
||||||
ProtoMinor: 0,
|
ProtoMinor: 0,
|
||||||
Header: http.Header{},
|
Header: http.Header{"Content-Type": {"text/plain"}},
|
||||||
ContentLength: int64(body.Len()),
|
ContentLength: int64(len(err.Error())),
|
||||||
Body: io.NopCloser(body),
|
Body: io.NopCloser(strings.NewReader(err.Error())),
|
||||||
Close: false,
|
Close: false,
|
||||||
Request: req,
|
Request: req,
|
||||||
}, nil
|
}, nil
|
||||||
|
@@ -60,7 +60,7 @@ func (t transport) RoundTrip(req *http.Request) (resp *http.Response, err error)
|
|||||||
Proto: "HTTP/1.0",
|
Proto: "HTTP/1.0",
|
||||||
ProtoMajor: 1,
|
ProtoMajor: 1,
|
||||||
ProtoMinor: 0,
|
ProtoMinor: 0,
|
||||||
Header: http.Header{},
|
Header: http.Header{"Content-Type": {"text/plain"}},
|
||||||
ContentLength: int64(body.Len()),
|
ContentLength: int64(body.Len()),
|
||||||
Body: io.NopCloser(body),
|
Body: io.NopCloser(body),
|
||||||
Close: false,
|
Close: false,
|
||||||
@@ -84,7 +84,8 @@ func (t transport) RoundTrip(req *http.Request) (resp *http.Response, err error)
|
|||||||
Proto: "HTTP/1.0",
|
Proto: "HTTP/1.0",
|
||||||
ProtoMajor: 1,
|
ProtoMajor: 1,
|
||||||
ProtoMinor: 0,
|
ProtoMinor: 0,
|
||||||
Header: header,
|
Header: http.Header{"Content-Type": {"text/plain"}},
|
||||||
|
ContentLength: int64(len(err.Error())),
|
||||||
Body: io.NopCloser(strings.NewReader(err.Error())),
|
Body: io.NopCloser(strings.NewReader(err.Error())),
|
||||||
Close: false,
|
Close: false,
|
||||||
Request: req,
|
Request: req,
|
||||||
|
Reference in New Issue
Block a user