Browse Source

Add the error when return 200OK but body contains the error

tags/v0.7.8
toranger 6 years ago
parent
commit
3ba85d66a2
  1. 6
      object.go
  2. 7
      object_part.go

6
object.go

@ -231,6 +231,12 @@ func (s *ObjectService) Copy(ctx context.Context, name, sourceURL string, opt *O
result: &res, result: &res,
} }
resp, err := s.client.send(ctx, &sendOpt) resp, err := s.client.send(ctx, &sendOpt)
// If the error occurs during the copy operation, the error response is embedded in the 200 OK response. This means that a 200 OK response can contain either a success or an error.
if err == nil && resp.StatusCode == 200 {
if res.ETag == "" {
return &res, resp, errors.New("response 200 OK, but body contains an error")
}
}
return &res, resp, err return &res, resp, err
} }

7
object_part.go

@ -3,6 +3,7 @@ package cos
import ( import (
"context" "context"
"encoding/xml" "encoding/xml"
"errors"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
@ -162,6 +163,12 @@ func (s *ObjectService) CompleteMultipartUpload(ctx context.Context, name, uploa
result: &res, result: &res,
} }
resp, err := s.client.send(ctx, &sendOpt) resp, err := s.client.send(ctx, &sendOpt)
// If the error occurs during the copy operation, the error response is embedded in the 200 OK response. This means that a 200 OK response can contain either a success or an error.
if err == nil && resp.StatusCode == 200 {
if res.ETag == "" {
return &res, resp, errors.New("response 200 OK, but body contains an error")
}
}
return &res, resp, err return &res, resp, err
} }

Loading…
Cancel
Save