Amazon.S3.AmazonS3HttpUtil.GetHeadAsync C# (CSharp) Method

GetHeadAsync() static private method

static private GetHeadAsync ( IAmazonS3 s3Client, IClientConfig config, string url, string header ) : Task
s3Client IAmazonS3
config IClientConfig
url string
header string
return Task
        internal static async Task<GetHeadResponse> GetHeadAsync(IAmazonS3 s3Client, IClientConfig config, string url, string header)
        {
            if (s3Client != null)
            {
                using (var httpClient = GetHttpClient(config))
                {
                    var request = new HttpRequestMessage(HttpMethod.Head, url);
                    var response = await httpClient.SendAsync(request).ConfigureAwait(false);
                    foreach (var headerPair in response.Headers)
                    {
                        if (string.Equals(headerPair.Key, HeaderKeys.XAmzBucketRegion, StringComparison.OrdinalIgnoreCase))
                        {
                            foreach (var value in headerPair.Value)
                            {
                                // If there's more than one there's something really wrong.
                                // So just use the first one anyway.
                                return new GetHeadResponse
                                {
                                    HeaderValue = value,
                                    StatusCode = response.StatusCode
                                };
                            }
                        }
                    }
                }
            }
            return null;
        }