encode() public method

public encode ( ) : string
return string
Ejemplo n.º 1
0
        private static async void doHttp(SdSource source, String url, Dictionary<String, String> args, SdNode config, __CacheBlock cache, HttpCallback callback) {


            var encoding = Encoding.GetEncoding(config.encode());

            AsyncHttpClient client = new AsyncHttpClient();

            if (config.isInCookie() && string.IsNullOrEmpty(source.cookies()) == false) {
                client.Cookies(source.cookies());
            }

            client.Header("User-Agent", source.ua());
            client.Encoding(config.encode());

            string newUrl = null;
            if (url.IndexOf(" ") >= 0)
                newUrl = Uri.EscapeUriString(url);
            else
                newUrl = url;

            if (config.isInReferer()) {
                client.Header("Referer", source.buildReferer(config, url));
            }

            if (string.IsNullOrEmpty(config.accept) == false) {
                client.Header("Accept", config.accept);
                client.Header("X-Requested-With", "XMLHttpRequest");
            }

            client.Url(newUrl);

            string temp = null;

            try {
                AsyncHttpResponse rsp = null;
                if ("post".Equals(config.method))
                    rsp = await client.Post(args);
                else
                    rsp = await client.Get();

                if (rsp.StatusCode == HttpStatusCode.Ok) {
                    source.setCookies(rsp.Cookies);
                    temp = rsp.GetString();
                }
            }
            catch(Exception ex) {
                Util.log(source, "HTTP", ex.Message);
            }

            if (temp == null) {
                if (cache == null)
                    callback(-2, null);
                else
                    callback(1, cache.value);
            }
            else
                callback(1, temp);
        }
Ejemplo n.º 2
0
Archivo: Util.cs Proyecto: noear/SiteD
        //----------

        public static String urlEncode(String str, SdNode config)
        {
            try
            {
                if(config.encode().ToLower() == "utf-8")
                    return Uri.EscapeUriString(str);
                else
                    return __Escape.JsEscape(str);
            }
            catch (Exception)
            {
                return "";
            }
        }
Ejemplo n.º 3
0
        //----------

        public static String urlEncode(String str, SdNode config)
        {
            try
            {
                if (config.encode().ToLower() == "utf-8")
                {
                    return(Uri.EscapeUriString(str));
                }
                else
                {
                    return(__Escape.JsEscape(str));
                }
            }
            catch (Exception)
            {
                return("");
            }
        }
Ejemplo n.º 4
0
        public void rebuild(SdNode cfg)
        {
            if (cfg != null)
            {
                this.config = cfg;
            }

            ua     = config.ua();
            encode = config.encode();
            method = config.method;


            if (config.isInCookie())
            {
                String cookies = config.cookies(url);
                if (cookies != null)
                {
                    header.Add("Cookie", cookies);
                }
            }

            if (config.isInReferer())
            {
                header.Add("Referer", config.getReferer(url));
            }

            if (config.isEmptyHeader() == false)
            {
                foreach (String kv in config.getHeader(url).Split(';'))
                {
                    String[] kv2 = kv.Split('=');
                    if (kv2.Length == 2)
                    {
                        header.Add(kv2[0], kv2[1]);
                    }
                }
            }
        }