mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-03-27 20:30:27 +02:00
Fix and improve S3 transport
This commit is contained in:
parent
53c3a6370a
commit
3c44af8d4e
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Fix
|
### Fix
|
||||||
|
- Fix `s3` scheme status codes.
|
||||||
- (pro) Fix saving animations to MP4.
|
- (pro) Fix saving animations to MP4.
|
||||||
|
|
||||||
## [3.3.2] - 2022-03-17
|
## [3.3.2] - 2022-03-17
|
||||||
|
@ -2,7 +2,9 @@ package s3
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
http "net/http"
|
http "net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
@ -60,8 +62,21 @@ func (t transport) RoundTrip(req *http.Request) (resp *http.Response, err error)
|
|||||||
s3req, _ := t.svc.GetObjectRequest(input)
|
s3req, _ := t.svc.GetObjectRequest(input)
|
||||||
|
|
||||||
if err := s3req.Send(); err != nil {
|
if err := s3req.Send(); err != nil {
|
||||||
if s3err, ok := err.(awserr.RequestFailure); !ok || s3err.StatusCode() != http.StatusNotModified {
|
if s3err, ok := err.(awserr.RequestFailure); !ok || s3err.StatusCode() < 100 || s3err.StatusCode() == 301 {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
} else {
|
||||||
|
body := strings.NewReader(s3err.Message())
|
||||||
|
return &http.Response{
|
||||||
|
StatusCode: s3err.StatusCode(),
|
||||||
|
Proto: "HTTP/1.0",
|
||||||
|
ProtoMajor: 1,
|
||||||
|
ProtoMinor: 0,
|
||||||
|
Header: http.Header{},
|
||||||
|
ContentLength: int64(body.Len()),
|
||||||
|
Body: io.NopCloser(body),
|
||||||
|
Close: false,
|
||||||
|
Request: s3req.HTTPRequest,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user