diff options
Diffstat (limited to 'vendor/github.com/aws/aws-sdk-go/service/s3/statusok_error.go')
-rw-r--r-- | vendor/github.com/aws/aws-sdk-go/service/s3/statusok_error.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/vendor/github.com/aws/aws-sdk-go/service/s3/statusok_error.go b/vendor/github.com/aws/aws-sdk-go/service/s3/statusok_error.go new file mode 100644 index 0000000..5a78fd3 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/s3/statusok_error.go | |||
@@ -0,0 +1,35 @@ | |||
1 | package s3 | ||
2 | |||
3 | import ( | ||
4 | "bytes" | ||
5 | "io/ioutil" | ||
6 | "net/http" | ||
7 | |||
8 | "github.com/aws/aws-sdk-go/aws/awserr" | ||
9 | "github.com/aws/aws-sdk-go/aws/request" | ||
10 | ) | ||
11 | |||
12 | func copyMultipartStatusOKUnmarhsalError(r *request.Request) { | ||
13 | b, err := ioutil.ReadAll(r.HTTPResponse.Body) | ||
14 | if err != nil { | ||
15 | r.Error = awserr.New("SerializationError", "unable to read response body", err) | ||
16 | return | ||
17 | } | ||
18 | body := bytes.NewReader(b) | ||
19 | r.HTTPResponse.Body = ioutil.NopCloser(body) | ||
20 | defer body.Seek(0, 0) | ||
21 | |||
22 | if body.Len() == 0 { | ||
23 | // If there is no body don't attempt to parse the body. | ||
24 | return | ||
25 | } | ||
26 | |||
27 | unmarshalError(r) | ||
28 | if err, ok := r.Error.(awserr.Error); ok && err != nil { | ||
29 | if err.Code() == "SerializationError" { | ||
30 | r.Error = nil | ||
31 | return | ||
32 | } | ||
33 | r.HTTPResponse.StatusCode = http.StatusServiceUnavailable | ||
34 | } | ||
35 | } | ||