From 3e632a49ee39102484c9f16abd3bbac320519265 Mon Sep 17 00:00:00 2001 From: Krishna Srinivas Date: Wed, 13 Sep 2017 17:27:19 -0700 Subject: [PATCH] In gateway mode "continuation-token" will not contain "prefix" (#4911) fixes #4900 --- cmd/bucket-handlers-listobjects.go | 20 ++++++++++++++++++++ cmd/gateway-handlers.go | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/cmd/bucket-handlers-listobjects.go b/cmd/bucket-handlers-listobjects.go index d69666d53..6389d3034 100644 --- a/cmd/bucket-handlers-listobjects.go +++ b/cmd/bucket-handlers-listobjects.go @@ -51,6 +51,26 @@ func validateListObjectsArgs(prefix, marker, delimiter string, maxKeys int) APIE return ErrNone } +// Validate all the ListObjectsV2 query arguments, returns an APIErrorCode +// if one of the args do not meet the required conditions. +// Special conditions required by Minio server are as below +// - delimiter if set should be equal to '/', otherwise the request is rejected. +func validateGatewayListObjectsV2Args(prefix, marker, delimiter string, maxKeys int) APIErrorCode { + // Max keys cannot be negative. + if maxKeys < 0 { + return ErrInvalidMaxKeys + } + + /// Minio special conditions for ListObjects. + + // Verify if delimiter is anything other than '/', which we do not support. + if delimiter != "" && delimiter != "/" { + return ErrNotImplemented + } + + return ErrNone +} + // ListObjectsV2Handler - GET Bucket (List Objects) Version 2. // -------------------------- // This implementation of the GET operation returns some or all (up to 1000) diff --git a/cmd/gateway-handlers.go b/cmd/gateway-handlers.go index 144d7144b..017457b3d 100644 --- a/cmd/gateway-handlers.go +++ b/cmd/gateway-handlers.go @@ -800,7 +800,7 @@ func (api gatewayAPIHandlers) ListObjectsV2Handler(w http.ResponseWriter, r *htt // Validate the query params before beginning to serve the request. // fetch-owner is not validated since it is a boolean - if s3Error := validateListObjectsArgs(prefix, marker, delimiter, maxKeys); s3Error != ErrNone { + if s3Error := validateGatewayListObjectsV2Args(prefix, marker, delimiter, maxKeys); s3Error != ErrNone { writeErrorResponse(w, s3Error, r.URL) return }