Browse Source

s3: return 404 if bucket does not exist

fix https://github.com/chrislusf/seaweedfs/issues/2039
pull/2050/head
Chris Lu 4 years ago
parent
commit
e87e6ef33c
  1. 15
      weed/s3api/s3api_objects_list_handlers.go

15
weed/s3api/s3api_objects_list_handlers.go

@ -63,6 +63,14 @@ func (s3a *S3ApiServer) ListObjectsV2Handler(w http.ResponseWriter, r *http.Requ
writeErrorResponse(w, s3err.ErrInternalError, r.URL)
return
}
if len(response.Contents) == 0 {
if exists, existErr := s3a.exists(s3a.option.BucketsPath, bucket, true); existErr == nil && !exists {
writeErrorResponse(w, s3err.ErrNoSuchBucket, r.URL)
return
}
}
responseV2 := &ListBucketResultV2{
XMLName: response.XMLName,
Name: response.Name,
@ -106,6 +114,13 @@ func (s3a *S3ApiServer) ListObjectsV1Handler(w http.ResponseWriter, r *http.Requ
return
}
if len(response.Contents) == 0 {
if exists, existErr := s3a.exists(s3a.option.BucketsPath, bucket, true); existErr == nil && !exists {
writeErrorResponse(w, s3err.ErrNoSuchBucket, r.URL)
return
}
}
writeSuccessResponseXML(w, encodeResponse(response))
}

Loading…
Cancel
Save