diff --git a/KS3/KS3Client.cs b/KS3/KS3Client.cs index 06246cae3487aebf1013a06c9dbe699390268b70..7d81aa2f9c14dcb2cd7ccd922c503d7e5b5e71b4 100644 --- a/KS3/KS3Client.cs +++ b/KS3/KS3Client.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.IO; using System.Security.Cryptography; - +using System.Text.RegularExpressions; using KS3.Model; using KS3.Auth; using KS3.Http; @@ -965,7 +965,7 @@ namespace KS3 * Three parameters needed to be set * 1. http method (GET, PUT, HEAD or DELETE) * 2. endpoint (http or https, and the host name. e.g. http://ks3-cn-beijing.ksyuncs.com) - * 3. resource path (bucketName/[key], e.g. my-bucket/my-object) + * 3. resource path (bucketName/[key], e.g. my-bucket/my-object) * 4. support Third-level Domain Name, e.g. my-bucket.endpoint/my-object */ private Request createRequest(String bucketName, String key, X originalRequest, HttpMethod httpMethod) where X : KS3Request @@ -976,7 +976,7 @@ namespace KS3 String host = endpoint.Host; Uri newEndpoint = endpoint; var newUriBuilder = new UriBuilder(endpoint); - if (bucketName != null && !host.StartsWith(bucketName)) { + if (bucketName != null && !host.StartsWith(bucketName)) { newUriBuilder.Host = bucketName + '.' + host; newEndpoint = newUriBuilder.Uri; } @@ -1107,6 +1107,8 @@ namespace KS3 private static string filterSpecial(string key) { if(!String.IsNullOrEmpty(key)){ key = key.Replace("%5C","/").Replace("//", "/%2F").Replace("%28", "(").Replace("%29",")"); + key = Regex.Replace(key, "%7E", "~", RegexOptions.IgnoreCase); + } return key; }