Beispiel #1
0
        public static bool GetApplicationMetadataFromHeaders(NameValueCollection headers, string requestVersion, NameValueCollection metadata)
        {
            int num;
            int num1;

            return(HttpRequestAccessorCommon.GetApplicationMetadataFromHeaders(headers, requestVersion, metadata, out num, out num1));
        }
Beispiel #2
0
        public static NephosUriComponents GetNephosHostStyleUriComponents(Uri uri, string accountName)
        {
            string str;
            string str1;
            NephosUriComponents nephosUriComponent = new NephosUriComponents(accountName);

            string[]            uriPathSubStrings   = HttpRequestAccessor.GetUriPathSubStrings(uri, 2);
            NephosUriComponents nephosUriComponent1 = nephosUriComponent;

            if ((int)uriPathSubStrings.Length > 0)
            {
                str = HttpRequestAccessorCommon.TrimEndSlash(uriPathSubStrings[0]);
            }
            else
            {
                str = null;
            }
            nephosUriComponent1.ContainerName = str;
            NephosUriComponents nephosUriComponent2 = nephosUriComponent;

            if ((int)uriPathSubStrings.Length > 1)
            {
                str1 = HttpRequestAccessorCommon.TrimEndSlash(uriPathSubStrings[1]);
            }
            else
            {
                str1 = null;
            }
            nephosUriComponent2.RemainingPart = str1;
            return(nephosUriComponent);
        }
Beispiel #3
0
        public static string GetNephosOrStandardDateString(NameValueCollection headers)
        {
            string str = null;

            str = (HttpRequestAccessorCommon.GetHeaderValues(headers, "x-ms-date").Count <= 0 ? headers.GetValues("Date")[0] : MessageCanonicalizer.GetCanonicalizedHeaderValue(headers, "x-ms-date"));
            return(str);
        }
Beispiel #4
0
        public static string GetCanonicalizedHeaderValue(NameValueCollection headers, string key)
        {
            StringBuilder stringBuilder = new StringBuilder();
            string        empty         = string.Empty;

            foreach (string headerValue in HttpRequestAccessorCommon.GetHeaderValues(headers, key))
            {
                string str = headerValue.Replace("\r\n", string.Empty);
                stringBuilder.Append(empty);
                stringBuilder.Append(str);
                empty = ",";
            }
            return(stringBuilder.ToString());
        }
Beispiel #5
0
        public static NephosUriComponents GetNephosPathStyleUriComponents(Uri uri)
        {
            string str;
            string str1;
            string str2;
            NephosUriComponents nephosUriComponent = new NephosUriComponents()
            {
                IsUriPathStyle = true
            };

            string[]            uriPathSubStrings   = HttpRequestAccessorJuly09.GetUriPathSubStrings(uri, 3);
            NephosUriComponents nephosUriComponent1 = nephosUriComponent;

            if ((int)uriPathSubStrings.Length > 0)
            {
                str = HttpRequestAccessorCommon.TrimEndSlash(uriPathSubStrings[0]);
            }
            else
            {
                str = null;
            }
            nephosUriComponent1.AccountName = str;
            NephosUriComponents nephosUriComponent2 = nephosUriComponent;

            if ((int)uriPathSubStrings.Length <= 1 || string.IsNullOrEmpty(uriPathSubStrings[1]))
            {
                str1 = null;
            }
            else
            {
                str1 = uriPathSubStrings[1];
            }
            nephosUriComponent2.ContainerName = str1;
            NephosUriComponents nephosUriComponent3 = nephosUriComponent;

            if ((int)uriPathSubStrings.Length <= 2 || string.IsNullOrEmpty(uriPathSubStrings[2]))
            {
                str2 = null;
            }
            else
            {
                str2 = uriPathSubStrings[2];
            }
            nephosUriComponent3.RemainingPart = str2;
            nephosUriComponent.IsRemainingPartPresentButEmpty = ((int)uriPathSubStrings.Length <= 2 || uriPathSubStrings[2] == null ? false : uriPathSubStrings[2].Length == 0);
            return(nephosUriComponent);
        }
Beispiel #6
0
        public static NephosUriComponents GetNephosPathStyleUriComponents(Uri uri)
        {
            string str;
            string str1;
            string str2;
            NephosUriComponents nephosUriComponent = new NephosUriComponents()
            {
                IsUriPathStyle = true
            };

            string[]            uriPathSubStrings   = HttpRequestAccessor.GetUriPathSubStrings(uri, 3);
            NephosUriComponents nephosUriComponent1 = nephosUriComponent;

            if ((int)uriPathSubStrings.Length > 0)
            {
                str = HttpRequestAccessorCommon.TrimEndSlash(uriPathSubStrings[0]);
            }
            else
            {
                str = null;
            }
            nephosUriComponent1.AccountName = str;
            NephosUriComponents nephosUriComponent2 = nephosUriComponent;

            if ((int)uriPathSubStrings.Length > 1)
            {
                str1 = HttpRequestAccessorCommon.TrimEndSlash(uriPathSubStrings[1]);
            }
            else
            {
                str1 = null;
            }
            nephosUriComponent2.ContainerName = str1;
            NephosUriComponents nephosUriComponent3 = nephosUriComponent;

            if ((int)uriPathSubStrings.Length > 2)
            {
                str2 = HttpRequestAccessorCommon.TrimEndSlash(uriPathSubStrings[2]);
            }
            else
            {
                str2 = null;
            }
            nephosUriComponent3.RemainingPart = str2;
            return(nephosUriComponent);
        }
Beispiel #7
0
        public static string GetContentMD5(NameValueCollection headers)
        {
            string    empty        = string.Empty;
            ArrayList headerValues = HttpRequestAccessorCommon.GetHeaderValues(headers, "Content-MD5");

            if (headerValues.Count > 1)
            {
                CultureInfo invariantCulture = CultureInfo.InvariantCulture;
                object[]    objArray         = new object[] { "Content-MD5" };
                throw new HttpRequestDuplicateHeaderException(string.Format(invariantCulture, "The given HTTP request header contains more than one {0} values.", objArray));
            }
            if (headerValues.Count == 1)
            {
                empty = (string)headerValues[0];
            }
            return(empty);
        }
Beispiel #8
0
        public static string CanonicalizeHttpRequestDefault(Uri address, NephosUriComponents uriComponents, string method, string contentType, NameValueCollection headers, bool isFileService = false, string rawUrl = null)
        {
            MessageCanonicalizer.CanonicalizedString canonicalizedString = new MessageCanonicalizer.CanonicalizedString(method);
            canonicalizedString.AppendCanonicalizedElement(MessageCanonicalizer.GetContentMD5(headers));
            canonicalizedString.AppendCanonicalizedElement(contentType);
            string str = null;

            if (HttpRequestAccessorCommon.GetHeaderValues(headers, "x-ms-date").Count <= 0)
            {
                string[] values = headers.GetValues("Date");
                str = (values == null || (int)values.Length == 0 ? string.Empty : values[0]);
            }
            else
            {
                str = null;
            }
            canonicalizedString.AppendCanonicalizedElement(str);
            ArrayList arrayLists = new ArrayList();

            foreach (string key in headers.Keys)
            {
                if (key == null || !key.ToLowerInvariant().StartsWith("x-ms-", StringComparison.Ordinal))
                {
                    continue;
                }
                arrayLists.Add(key.ToLowerInvariant());
            }
            arrayLists.Sort();
            foreach (string arrayList in arrayLists)
            {
                string canonicalizedHeaderValue = MessageCanonicalizer.GetCanonicalizedHeaderValue(headers, arrayList);
                if (string.IsNullOrEmpty(canonicalizedHeaderValue) && !isFileService && MessageCanonicalizer.IsVersionBeforeFeb16(headers["x-ms-version"]))
                {
                    continue;
                }
                StringBuilder stringBuilder = new StringBuilder(arrayList);
                stringBuilder.Append(":");
                stringBuilder.Append(canonicalizedHeaderValue);
                canonicalizedString.AppendCanonicalizedElement(stringBuilder.ToString());
            }
            canonicalizedString.AppendCanonicalizedElement(MessageCanonicalizer.GetCanonicalizedResource(address, uriComponents, rawUrl));
            return(canonicalizedString.Value);
        }
Beispiel #9
0
        internal static Uri GetRequestUriInternal(Uri listenerRequestUri, string rawUrl, string hostHeader)
        {
            Uri uri;

            if (listenerRequestUri == null)
            {
                throw new InvalidUrlException(string.Format("request.Url is null; RawUrl={0}, HostHeader={1}", rawUrl, hostHeader));
            }
            if (string.IsNullOrEmpty(rawUrl))
            {
                throw new ArgumentException("request.RawUrl is null or empty", "request.RawUrl");
            }
            UriBuilder uriBuilder = new UriBuilder()
            {
                Scheme = listenerRequestUri.Scheme,
                Host   = listenerRequestUri.Host
            };
            int?nullable = null;

            if (!HttpUtilities.TryGetPortFromHostHeaderValue(hostHeader, out nullable))
            {
                uriBuilder.Port = listenerRequestUri.Port;
            }
            else if (nullable.HasValue)
            {
                uriBuilder.Port = nullable.Value;
            }
            if (!rawUrl.StartsWith("/"))
            {
                uri = (rawUrl != "*" ? new Uri(rawUrl) : new Uri(string.Concat(uriBuilder.Uri.AbsoluteUri, rawUrl)));
            }
            else
            {
                uri = new Uri(string.Concat(HttpRequestAccessorCommon.TrimEndSlash(uriBuilder.Uri.AbsoluteUri), rawUrl));
            }
            uriBuilder.Path = uri.AbsolutePath;
            if (!string.IsNullOrEmpty(uri.Query))
            {
                uriBuilder.Query = HttpUtilities.QueryWithoutQuestionMark(uri.Query);
            }
            return(uriBuilder.Uri);
        }
Beispiel #10
0
        public static void GetAuthorizationFieldValues(NameValueCollection headers, string authHeaderName, out string authScheme, out string authSchemeParam)
        {
            ArrayList headerValues = HttpRequestAccessorCommon.GetHeaderValues(headers, authHeaderName);

            if (headerValues.Count == 0)
            {
                CultureInfo invariantCulture = CultureInfo.InvariantCulture;
                object[]    objArray         = new object[] { "Authorization" };
                throw new HttpRequestHeaderNotFoundException(string.Format(invariantCulture, "No '{0}' header found.", objArray));
            }
            if (headerValues.Count > 1)
            {
                CultureInfo   cultureInfo   = CultureInfo.InvariantCulture;
                object[]      objArray1     = new object[] { "Authorization" };
                StringBuilder stringBuilder = new StringBuilder(string.Format(cultureInfo, "More than one '{0}' header values found ", objArray1));
                string        str           = ":";
                foreach (string headerValue in headerValues)
                {
                    stringBuilder.Append(str);
                    stringBuilder.Append(headerValue);
                    str = ",";
                }
                throw new HttpRequestDuplicateHeaderException(stringBuilder.ToString());
            }
            string item = (string)headerValues[0];

            string[] strArrays = item.Split(HttpRequestAccessorCommon.spaceDelimiter, StringSplitOptions.RemoveEmptyEntries);
            if ((int)strArrays.Length != 2)
            {
                CultureInfo invariantCulture1 = CultureInfo.InvariantCulture;
                object[]    objArray2         = new object[] { "Authorization", item };
                throw new HttpRequestInvalidHeaderException(string.Format(invariantCulture1, "{0} value '{1}' is invalid.", objArray2));
            }
            authScheme      = strArrays[0];
            authSchemeParam = strArrays[1];
        }
Beispiel #11
0
        public static string GetRangeHeaderValue(NameValueCollection headers)
        {
            string str;

            return(HttpRequestAccessorCommon.GetRangeHeaderValue(headers, out str));
        }
Beispiel #12
0
 public static DateTime?GetNephosOrStandardDateHeader(NameValueCollection requestHeaders)
 {
     return(HttpRequestAccessorCommon.ExtractAndVerifyDate(requestHeaders["x-ms-date"] ?? requestHeaders["Date"]));
 }
Beispiel #13
0
 public static ArrayList GetHeaderValues(WebRequest request, string headerName)
 {
     return(HttpRequestAccessorCommon.GetHeaderValues(request.Headers, headerName));
 }
Beispiel #14
0
 public static void GetAuthorizationFieldValues(NameValueCollection headers, out string authScheme, out string authSchemeParam)
 {
     HttpRequestAccessorCommon.GetAuthorizationFieldValues(headers, "Authorization", out authScheme, out authSchemeParam);
 }
Beispiel #15
0
 private static string GetCanonicalizedHeaderValueVer1(NameValueCollection headers, string key, bool multipleConditionalHeadersEnabled)
 {
     return(HttpRequestAccessorCommon.GetHeaderValue(headers, key, multipleConditionalHeadersEnabled));
 }