Example #1
0
        public static string ConstructCopySourceResource(string accountName, string containerName, string blobName)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("/");
            stringBuilder.Append(accountName);
            if (!string.IsNullOrEmpty(containerName))
            {
                stringBuilder.Append("/");
                stringBuilder.Append(containerName);
            }
            if (!string.IsNullOrEmpty(blobName))
            {
                stringBuilder.Append("/");
                stringBuilder.Append(blobName);
            }
            return(HttpUtilities.PathEncode(stringBuilder.ToString()));
        }
Example #2
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);
        }
Example #3
0
        public static string ConstructCopySourceResource(string accountName, string containerName, string blobName, DateTime?snapshot)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("/");
            stringBuilder.Append(accountName);
            if (!string.IsNullOrEmpty(containerName))
            {
                stringBuilder.Append("/");
                stringBuilder.Append(containerName);
            }
            if (!string.IsNullOrEmpty(blobName))
            {
                stringBuilder.Append("/");
                stringBuilder.Append(blobName);
            }
            string str = (snapshot.HasValue ? HttpUtilities.GetSnapshotQueryParameterStringForUrl(snapshot.Value) : string.Empty);

            return(string.Concat(HttpUtilities.PathEncode(stringBuilder.ToString()), str));
        }
Example #4
0
 public static bool IsHttpRestrictedCodepoint(int codePoint)
 {
     if (codePoint > 31 && codePoint < 127)
     {
         return(false);
     }
     if (HttpUtilities.IsValidUnicodeChar(codePoint))
     {
         if (codePoint >= 0 && codePoint <= 31 || codePoint == 127 || codePoint == 129 || codePoint == 141 || codePoint == 143 || codePoint == 144 || codePoint == 157)
         {
             return(true);
         }
         if (codePoint >= 63745 && codePoint <= 65501 && HttpUtilities.PercentEncodeUtf8ContainsRestrictedChar(codePoint))
         {
             return(true);
         }
     }
     else if (HttpUtilities.PercentEncodeUtf8ContainsRestrictedChar(codePoint))
     {
         return(true);
     }
     return(false);
 }
Example #5
0
 public static NephosUriComponents GetNephosUriComponents(IHttpListenerRequest request, string[] hostSuffixes, bool allowPathStyleUri)
 {
     return(HttpRequestAccessorJuly09.GetNephosUriComponents(HttpUtilities.GetRequestUri(request), hostSuffixes, allowPathStyleUri));
 }
Example #6
0
 private static Uri ConstructUriFromUriAndString(Uri endpoint, string path)
 {
     return(new Uri(endpoint, HttpUtilities.PathEncode(path)));
 }
Example #7
0
 public static string QueryParameterValueEncode(string queryParamValue)
 {
     return(HttpUtilities.QueryParameterNameEncode(queryParamValue));
 }
Example #8
0
        private static bool PercentEncodeUtf8ContainsRestrictedChar(int unicodeChar)
        {
            if (unicodeChar <= 127)
            {
                return(HttpUtilities.IsExtendedAsciiRestrictedChar((char)(127 & unicodeChar)));
            }
            if (unicodeChar <= 2047)
            {
                char chr  = 'À';
                char chr1 = '\u0080';
                chr = (char)(chr | (char)((unicodeChar & 1984) >> 6));
                if (HttpUtilities.IsExtendedAsciiRestrictedChar((char)(chr1 | (char)(unicodeChar & 63))))
                {
                    return(true);
                }
                return(HttpUtilities.IsExtendedAsciiRestrictedChar(chr));
            }
            if (unicodeChar <= 65535)
            {
                char chr2 = 'à';
                char chr3 = '\u0080';
                char chr4 = '\u0080';
                chr2 = (char)(chr2 | (char)((unicodeChar & 61440) >> 12));
                chr3 = (char)(chr3 | (char)((unicodeChar & 4032) >> 6));
                if (HttpUtilities.IsExtendedAsciiRestrictedChar((char)(chr4 | (char)(unicodeChar & 63))) || HttpUtilities.IsExtendedAsciiRestrictedChar(chr3))
                {
                    return(true);
                }
                return(HttpUtilities.IsExtendedAsciiRestrictedChar(chr2));
            }
            if (unicodeChar > 2097151)
            {
                return(false);
            }
            char chr5 = 'ð';
            char chr6 = '\u0080';
            char chr7 = '\u0080';
            char chr8 = '\u0080';

            chr5 = (char)(chr5 | (char)((unicodeChar & 1835008) >> 18));
            chr6 = (char)(chr6 | (char)((unicodeChar & 258048) >> 12));
            chr7 = (char)(chr7 | (char)((unicodeChar & 4032) >> 6));
            if (HttpUtilities.IsExtendedAsciiRestrictedChar((char)(chr8 | (char)(unicodeChar & 63))) || HttpUtilities.IsExtendedAsciiRestrictedChar(chr7) || HttpUtilities.IsExtendedAsciiRestrictedChar(chr6))
            {
                return(true);
            }
            return(HttpUtilities.IsExtendedAsciiRestrictedChar(chr5));
        }
Example #9
0
 public static string GetSnapshotQueryParameterStringForUrl(DateTime snapshot)
 {
     return(string.Format("?{0}={1}", "snapshot", HttpUtilities.PathEncode(HttpUtilities.ConvertSnapshotDateTimeToHttpString(snapshot))));
 }
Example #10
0
 public static Uri GetRequestUri(IHttpListenerRequest request)
 {
     return(HttpUtilities.GetRequestUriInternal(request.Url, request.RawUrl, request.UserHostName));
 }