Skip to content

Commit

Permalink
fix case sensitive comparison for headers (#269)
Browse files Browse the repository at this point in the history
pass sse headers for StatObjectAsync call
  • Loading branch information
poornas authored and nitisht committed Jan 9, 2019
1 parent d1f6255 commit 2a519e3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions Minio.Functional.Tests/FunctionalTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ public static void Main(string[] args)
String endPoint = null;
String accessKey = null;
String secretKey = null;
String enableHttps = "0";
String kmsEnabled = "0";
string enableHttps = "0";
string kmsEnabled = "0";

bool useAWS = Environment.GetEnvironmentVariable("AWS_ENDPOINT") != null;
if (Environment.GetEnvironmentVariable("SERVER_ENDPOINT") != null)
Expand All @@ -136,6 +136,7 @@ public static void Main(string[] args)
accessKey = "Q3AM3UQ867SPQQA43P2F";
secretKey = "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG";
enableHttps = "1";
kmsEnabled = "1";
}

MinioClient minioClient = null;
Expand All @@ -154,7 +155,7 @@ public static void Main(string[] args)
// Set app Info
minioClient.SetAppInfo("app-name", "app-version");
// Set HTTP Tracing On
//minioClient.SetTraceOn(new JsonNetLogger());
// minioClient.SetTraceOn(new JsonNetLogger());

// Set HTTP Tracing Off
// minioClient.SetTraceOff();
Expand Down Expand Up @@ -256,7 +257,7 @@ public static void Main(string[] args)
EncryptedCopyObject_Test1(minioClient).Wait();
EncryptedCopyObject_Test2(minioClient).Wait();
}
if (kmsEnabled.Equals("1"))
if (kmsEnabled != null && kmsEnabled.Equals("1"))
{
PutGetStatEncryptedObject_Test3(minioClient).Wait();
EncryptedCopyObject_Test3(minioClient).Wait();
Expand Down
8 changes: 4 additions & 4 deletions Minio/ApiEndpoints/ObjectOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public partial class MinioClient : IObjectOperations
/// <param name="cancellationToken">Optional cancellation token to cancel the operation</param>
public async Task GetObjectAsync(string bucketName, string objectName, Action<Stream> cb, ServerSideEncryption sse = null, CancellationToken cancellationToken = default(CancellationToken))
{
await StatObjectAsync(bucketName, objectName, cancellationToken:cancellationToken).ConfigureAwait(false);
await StatObjectAsync(bucketName, objectName, sse:sse, cancellationToken:cancellationToken).ConfigureAwait(false);

var headers = new Dictionary<string,string>();
if (sse != null && sse.GetType().Equals(EncryptionType.SSE_C))
Expand Down Expand Up @@ -823,19 +823,19 @@ private async Task<List<DeleteError>> removeObjectsAsync(string bucketName, List

foreach (Parameter parameter in response.Headers)
{
if (parameter.Name.Equals("Content-Length"))
if (parameter.Name.Equals("Content-Length", StringComparison.OrdinalIgnoreCase))
{
size = long.Parse(parameter.Value.ToString());
}
else if (parameter.Name.Equals("Last-Modified"))
else if (parameter.Name.Equals("Last-Modified", StringComparison.OrdinalIgnoreCase))
{
lastModified = DateTime.Parse(parameter.Value.ToString());
}
else if (parameter.Name.Equals("ETag", StringComparison.OrdinalIgnoreCase))
{
etag = parameter.Value.ToString().Replace("\"", "");
}
else if (parameter.Name.Equals("Content-Type"))
else if (parameter.Name.Equals("Content-Type", StringComparison.OrdinalIgnoreCase))
{
contentType = parameter.Value.ToString();
metaData["Content-Type"] = contentType;
Expand Down
2 changes: 1 addition & 1 deletion Minio/DataModel/CopyConditions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public bool HasReplaceMetadataDirective()
{
foreach (var item in copyConditions)
{
if (item.Key.Equals("x-amz-metadata-directive") &&
if (item.Key.Equals("x-amz-metadata-directive", StringComparison.OrdinalIgnoreCase) &&
(item.Value.ToUpper().Equals("REPLACE")))
return true;
}
Expand Down

0 comments on commit 2a519e3

Please sign in to comment.