s3: Fix compliance bugs reported by s3verify. (#2624)

- Fixes couple of error strings reported are mismatching.
- Fixes a error HTTP status which was wrong fixed.
- Remove usage of an deprecated PostResponse, au contraire
  to their documentation there is no response body in
  PostPolicy.
master
Harshavardhana 8 years ago committed by GitHub
parent bc8f34bfe7
commit b291dbe9c5
  1. 6
      cmd/api-errors.go
  2. 10
      cmd/api-response.go
  3. 11
      cmd/bucket-handlers.go

@ -263,7 +263,7 @@ var errorCodeResponse = map[APIErrorCode]APIError{
}, },
ErrNoSuchBucketPolicy: { ErrNoSuchBucketPolicy: {
Code: "NoSuchBucketPolicy", Code: "NoSuchBucketPolicy",
Description: "The specified bucket does not have a bucket policy.", Description: "The bucket policy does not exist",
HTTPStatusCode: http.StatusNotFound, HTTPStatusCode: http.StatusNotFound,
}, },
ErrNoSuchKey: { ErrNoSuchKey: {
@ -328,7 +328,7 @@ var errorCodeResponse = map[APIErrorCode]APIError{
}, },
ErrBucketNotEmpty: { ErrBucketNotEmpty: {
Code: "BucketNotEmpty", Code: "BucketNotEmpty",
Description: "The bucket you tried to delete is not empty.", Description: "The bucket you tried to delete is not empty",
HTTPStatusCode: http.StatusConflict, HTTPStatusCode: http.StatusConflict,
}, },
ErrAllAccessDisabled: { ErrAllAccessDisabled: {
@ -446,7 +446,7 @@ var errorCodeResponse = map[APIErrorCode]APIError{
ErrExpiredPresignRequest: { ErrExpiredPresignRequest: {
Code: "AccessDenied", Code: "AccessDenied",
Description: "Request has expired", Description: "Request has expired",
HTTPStatusCode: http.StatusBadRequest, HTTPStatusCode: http.StatusForbidden,
}, },
// FIXME: Actual XML error response also contains the header which missed in lsit of signed header parameters. // FIXME: Actual XML error response also contains the header which missed in lsit of signed header parameters.
ErrUnsignedHeaders: { ErrUnsignedHeaders: {

@ -226,16 +226,6 @@ type CompleteMultipartUploadResponse struct {
ETag string ETag string
} }
// PostResponse container for completed post upload response
type PostResponse struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ PostResponse" json:"-"`
Location string
Bucket string
Key string
ETag string
}
// DeleteError structure. // DeleteError structure.
type DeleteError struct { type DeleteError struct {
Code string Code string

@ -387,18 +387,15 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h
if md5Sum != "" { if md5Sum != "" {
w.Header().Set("ETag", "\""+md5Sum+"\"") w.Header().Set("ETag", "\""+md5Sum+"\"")
} }
encodedSuccessResponse := encodeResponse(PostResponse{
Location: getObjectLocation(bucket, object), // TODO Full URL is preferred // TODO full URL is preferred.
Bucket: bucket, w.Header().Set("Location", getObjectLocation(bucket, object))
Key: object,
ETag: md5Sum,
})
// Set common headers. // Set common headers.
setCommonHeaders(w) setCommonHeaders(w)
// Write successful response. // Write successful response.
writeSuccessResponse(w, encodedSuccessResponse) writeSuccessNoContent(w)
if eventN.IsBucketNotificationSet(bucket) { if eventN.IsBucketNotificationSet(bucket) {
// Fetch object info for notifications. // Fetch object info for notifications.

Loading…
Cancel
Save