]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blob - vendor/github.com/aws/aws-sdk-go/service/s3/statusok_error.go
Initial transfer of provider code
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / aws / aws-sdk-go / service / s3 / statusok_error.go
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 }