Beispiel #1
0
        private string GetCanonicalizedHeaders(System.Net.Http.Headers.HttpRequestHeaders requestHeaders, System.Net.Http.Headers.HttpContentHeaders contentHeaders = null)
        {
            string canonicalizedHeaders = "";
            //assuming orderby does the lexigraphical ordering required here?
            var headers = requestHeaders.Where(h => h.Key.StartsWith("x-ms-"));

            if (contentHeaders != null)
            {
                headers = headers.Union(contentHeaders.Where(h => h.Key.StartsWith("x-ms-")));
            }
            headers = headers.GroupBy(g => g.Key).Select(g => g.First()).OrderBy(h => h.Key);
            foreach (var header in headers)
            {
                canonicalizedHeaders += header.Key.ToLower() + ":";
                foreach (var headerValue in header.Value)
                {
                    canonicalizedHeaders += headerValue + ",";
                }
                canonicalizedHeaders = canonicalizedHeaders.TrimEnd(',') + "\n";
            }
            return(canonicalizedHeaders.TrimEnd('\n'));
        }