From 92fcee824bc67e9daf518b993bf865be3a71de9f Mon Sep 17 00:00:00 2001 From: "Peter A. Bigot" Date: Sun, 19 Apr 2015 08:29:01 -0500 Subject: [PATCH] curl: use pathrequeststyle option when constructing Host endpoint Buckets with mixed-case names can't be accessed with the virtual-hosted style API due to DNS limitations. S3FS has an option for pathrequeststyle which is used for the URL, but it was not applied when building the endpoint passed through the Host header. Fix this, and relax the validation on bucket names when using this style. See: http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro Signed-off-by: Peter A. Bigot --- src/curl.cpp | 3 +++ src/s3fs.cpp | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/curl.cpp b/src/curl.cpp index 7edcaab..f0c5cbe 100644 --- a/src/curl.cpp +++ b/src/curl.cpp @@ -121,7 +121,10 @@ static string url_to_host(const std::string &url) static string get_bucket_host() { + if(!pathrequeststyle){ return bucket + "." + url_to_host(host); + } + return url_to_host(host) + "/" + bucket; } #if 0 // noused diff --git a/src/s3fs.cpp b/src/s3fs.cpp index a67f9d2..2121355 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -4050,9 +4050,9 @@ int main(int argc, char* argv[]) exit(EXIT_FAILURE); } - // bucket names cannot contain upper case characters - if(lower(bucket) != bucket){ - fprintf(stderr, "%s: BUCKET %s, upper case characters are not supported\n", + // bucket names cannot contain upper case characters in virtual-hosted style + if((!pathrequeststyle) && (lower(bucket) != bucket)){ + fprintf(stderr, "%s: BUCKET %s, name not compatible with virtual-hosted style\n", program_name.c_str(), bucket.c_str()); exit(EXIT_FAILURE); }