public static string UnEscapeURL(string s, Encoding e)
        {
            bool   flag = s == null;
            string result;

            if (flag)
            {
                result = null;
            }
            else
            {
                bool flag2 = s.IndexOf('%') == -1 && s.IndexOf('+') == -1;
                if (flag2)
                {
                    result = s;
                }
                else
                {
                    byte[] bytes  = e.GetBytes(s);
                    byte[] bytes2 = WWWTranscoder.URLDecode(bytes);
                    result = e.GetString(bytes2);
                }
            }
            return(result);
        }
        public static string EscapeURL(string s, Encoding e)
        {
            bool   flag = s == null;
            string result;

            if (flag)
            {
                result = null;
            }
            else
            {
                bool flag2 = s == "";
                if (flag2)
                {
                    result = "";
                }
                else
                {
                    bool flag3 = e == null;
                    if (flag3)
                    {
                        result = null;
                    }
                    else
                    {
                        byte[] bytes  = e.GetBytes(s);
                        byte[] bytes2 = WWWTranscoder.URLEncode(bytes);
                        result = e.GetString(bytes2);
                    }
                }
            }
            return(result);
        }
예제 #3
0
        internal static string MakeInitialUrl(string targetUrl, string localUrl)
        {
            string result;

            if (targetUrl.StartsWith("jar:file://"))
            {
                result = targetUrl;
            }
            else if (targetUrl.StartsWith("blob:http"))
            {
                result = targetUrl;
            }
            else
            {
                Uri uri  = new Uri(localUrl);
                Uri uri2 = null;
                if (targetUrl[0] == '/')
                {
                    uri2 = new Uri(uri, targetUrl);
                }
                if (uri2 == null && WebRequestUtils.domainRegex.IsMatch(targetUrl))
                {
                    targetUrl = uri.Scheme + "://" + targetUrl;
                }
                FormatException ex = null;
                try
                {
                    if (uri2 == null && targetUrl[0] != '.')
                    {
                        uri2 = new Uri(targetUrl);
                    }
                }
                catch (FormatException ex2)
                {
                    ex = ex2;
                }
                if (uri2 == null)
                {
                    try
                    {
                        uri2 = new Uri(uri, targetUrl);
                    }
                    catch (FormatException)
                    {
                        throw ex;
                    }
                }
                if (targetUrl.StartsWith("file://", StringComparison.OrdinalIgnoreCase))
                {
                    result = ((!targetUrl.Contains("%")) ? targetUrl : WWWTranscoder.URLDecode(targetUrl, Encoding.UTF8));
                }
                else
                {
                    result = ((!targetUrl.Contains("%")) ? uri2.AbsoluteUri : uri2.OriginalString);
                }
            }
            return(result);
        }
예제 #4
0
        public static UnityWebRequest Post(string uri, string postData)
        {
            UnityWebRequest request = new UnityWebRequest(uri, "POST");
            string          s       = WWWTranscoder.URLEncode(postData, Encoding.UTF8);

            request.uploadHandler             = new UploadHandlerRaw(Encoding.UTF8.GetBytes(s));
            request.uploadHandler.contentType = "application/x-www-form-urlencoded";
            request.downloadHandler           = new DownloadHandlerBuffer();
            return(request);
        }
예제 #5
0
 private static void SetupPost(UnityWebRequest request, string postData)
 {
     byte[] data = null;
     if (!string.IsNullOrEmpty(postData))
     {
         string s = WWWTranscoder.DataEncode(postData, Encoding.UTF8);
         data = Encoding.UTF8.GetBytes(s);
     }
     request.uploadHandler             = new UploadHandlerRaw(data);
     request.uploadHandler.contentType = "application/x-www-form-urlencoded";
     request.downloadHandler           = new DownloadHandlerBuffer();
 }
예제 #6
0
파일: WWW.cs 프로젝트: zjn0206a/ShipGirlBot
 public static string UnEscapeURL(string s, Encoding e)
 {
     if (s == null)
     {
         return(null);
     }
     if ((s.IndexOf('%') == -1) && (s.IndexOf('+') == -1))
     {
         return(s);
     }
     return(WWWTranscoder.URLDecode(s, e));
 }
        public static byte[] SerializeSimpleForm(Dictionary <string, string> formFields)
        {
            string queryString = "";

            foreach (KeyValuePair <string, string> pair in formFields)
            {
                if (queryString.Length > 0)
                {
                    queryString += "&";
                }
                queryString += WWWTranscoder.DataEncode(pair.Key) + "=" + WWWTranscoder.DataEncode(pair.Value);
            }
            return(System.Text.Encoding.UTF8.GetBytes(queryString));
        }
        private static void SetupPostWwwForm(UnityWebRequest request, string postData)
        {
            request.downloadHandler = new DownloadHandlerBuffer();
            if (string.IsNullOrEmpty(postData))
            {
                return;  // no data to send, nothing more to setup
            }
            byte[] payload    = null;
            string urlencoded = WWWTranscoder.DataEncode(postData, System.Text.Encoding.UTF8);

            payload = System.Text.Encoding.UTF8.GetBytes(urlencoded);
            request.uploadHandler             = new UploadHandlerRaw(payload);
            request.uploadHandler.contentType = "application/x-www-form-urlencoded";
        }
        public static byte[] SerializeSimpleForm(Dictionary <string, string> formFields)
        {
            string text = "";

            foreach (KeyValuePair <string, string> keyValuePair in formFields)
            {
                if (text.Length > 0)
                {
                    text += "&";
                }
                text = text + WWWTranscoder.DataEncode(keyValuePair.Key) + "=" + WWWTranscoder.DataEncode(keyValuePair.Value);
            }
            return(Encoding.UTF8.GetBytes(text));
        }
예제 #10
0
        public static UnityWebRequest Post(string uri, string postData)
        {
            UnityWebRequest unityWebRequest = new UnityWebRequest(uri, "POST");

            byte[] data = null;
            if (!string.IsNullOrEmpty(postData))
            {
                string s = WWWTranscoder.URLEncode(postData, Encoding.UTF8);
                data = Encoding.UTF8.GetBytes(s);
            }
            unityWebRequest.uploadHandler             = new UploadHandlerRaw(data);
            unityWebRequest.uploadHandler.contentType = "application/x-www-form-urlencoded";
            unityWebRequest.downloadHandler           = new DownloadHandlerBuffer();
            return(unityWebRequest);
        }
예제 #11
0
파일: WWW.cs 프로젝트: zjn0206a/ShipGirlBot
 public static string EscapeURL(string s, Encoding e)
 {
     if (s == null)
     {
         return(null);
     }
     if (s == string.Empty)
     {
         return(string.Empty);
     }
     if (e == null)
     {
         return(null);
     }
     return(WWWTranscoder.URLEncode(s, e));
 }
        public static string UnEscapeURL(string s, Encoding e)
        {
            if (null == s)
            {
                return(null);
            }

            if (s.IndexOf('%') == -1 && s.IndexOf('+') == -1)
            {
                return(s);
            }

            var bytes        = e.GetBytes(s);
            var decodedBytes = WWWTranscoder.URLDecode(bytes);

            return(e.GetString(decodedBytes));
        }
예제 #13
0
        public static string UnEscapeURL(string s, Encoding e)
        {
            string result;

            if (s == null)
            {
                result = null;
            }
            else if (s.IndexOf('%') == -1 && s.IndexOf('+') == -1)
            {
                result = s;
            }
            else
            {
                result = WWWTranscoder.URLDecode(s, e);
            }
            return(result);
        }
예제 #14
0
        public static string UnEscapeURL(string s, Encoding e)
        {
            string result;

            if (s == null)
            {
                result = null;
            }
            else if (s.IndexOf('%') == -1 && s.IndexOf('+') == -1)
            {
                result = s;
            }
            else
            {
                byte[] bytes  = Encoding.UTF8.GetBytes(s);
                byte[] bytes2 = WWWTranscoder.URLDecode(bytes);
                result = e.GetString(bytes2);
            }
            return(result);
        }
        public static string EscapeURL(string s, Encoding e)
        {
            if (s == null)
            {
                return(null);
            }

            if (s == "")
            {
                return("");
            }

            if (e == null)
            {
                return(null);
            }

            var bytes        = e.GetBytes(s);
            var decodedBytes = WWWTranscoder.URLEncode(bytes);

            return(e.GetString(decodedBytes));
        }
예제 #16
0
        internal static string MakeUriString(Uri targetUri, string targetUrl, bool prependingProtocol)
        {
            string result;

            if (targetUrl.StartsWith("file://", StringComparison.OrdinalIgnoreCase))
            {
                if (targetUrl.Contains("%"))
                {
                    byte[] bytes  = Encoding.UTF8.GetBytes(targetUrl);
                    byte[] bytes2 = WWWTranscoder.URLDecode(bytes);
                    result = Encoding.UTF8.GetString(bytes2);
                }
                else
                {
                    result = targetUrl;
                }
            }
            else if (targetUrl.Contains("%"))
            {
                result = targetUri.OriginalString;
            }
            else
            {
                string scheme = targetUri.Scheme;
                if (!prependingProtocol && targetUrl.Length >= scheme.Length + 2 && targetUrl[scheme.Length + 1] != '/')
                {
                    StringBuilder stringBuilder = new StringBuilder(scheme, targetUrl.Length);
                    stringBuilder.Append(':');
                    stringBuilder.Append(targetUri.PathAndQuery);
                    stringBuilder.Append(targetUri.Fragment);
                    result = stringBuilder.ToString();
                }
                else
                {
                    result = targetUri.AbsoluteUri;
                }
            }
            return(result);
        }
예제 #17
0
        public static string EscapeURL(string s, Encoding e)
        {
            string result;

            if (s == null)
            {
                result = null;
            }
            else if (s == "")
            {
                result = "";
            }
            else if (e == null)
            {
                result = null;
            }
            else
            {
                result = WWWTranscoder.URLEncode(s, e);
            }
            return(result);
        }
예제 #18
0
        public static string EscapeURL(string s, Encoding e)
        {
            string result;

            if (s == null)
            {
                result = null;
            }
            else if (s == "")
            {
                result = "";
            }
            else if (e == null)
            {
                result = null;
            }
            else
            {
                byte[] bytes  = Encoding.UTF8.GetBytes(s);
                byte[] bytes2 = WWWTranscoder.URLEncode(bytes);
                result = e.GetString(bytes2);
            }
            return(result);
        }
예제 #19
0
 private static string URLDecode(string encoded)
 {
     byte[] bytes  = Encoding.UTF8.GetBytes(encoded);
     byte[] bytes2 = WWWTranscoder.URLDecode(bytes);
     return(Encoding.UTF8.GetString(bytes2));
 }