示例#1
0
        public override void Process(opis message)
        {
            opis trtrt = new opis();

            try
            {
                if (modelSpec.isHere(opis_json))
                {
                    trtrt.load(message.body);
                }
                else
                {
                    trtrt.JsonParce(message.body);
                }
            }
            catch (Exception e)
            {
                trtrt["error parce"].body = e.Message;
            }

            message.body = "";
            if (modelSpec.isHere(opis_json))
            {
                message.body = trtrt.body;
            }

            if (modelSpec.isHere(decode_names))
            {
                trtrt.RunRecursively(x => x.PartitionName = TemplatesMan.UTF8BigEndian_to_Kirill(x.PartitionName));
            }



            message.CopyArr(new opis());
            message.AddArr(trtrt);
        }
示例#2
0
        public override void Process(opis message)
        {
            opis rl = modelSpec[ReplaceList].Duplicate();

            instanse.ExecActionModel(rl, rl);
            //string data = message.body;

            opis dd = modelSpec[String_templ].Duplicate();

            instanse.ExecActionModel(dd, dd);
            string data = dd.body;

            opis t = modelSpec[values_container].Duplicate();

            instanse.ExecActionModel(t, t);

            //logopis.AddArr(t);

            if (modelSpec.isHere(use_container_names))
            {
                for (int i = 0; i < t.listCou; i++)
                {
                    string torepl      = "#" + t[i].PartitionName.Trim() + "#";
                    string replacement = t[i].body;

                    replacement = replacement.Trim(new char[] { '"' });

                    if (modelSpec.isHere(percent_symbol_encode))
                    {
                        replacement = replacement.Replace("%", "%25");
                    }

                    if (!modelSpec.isHere(no_slash_conversion))
                    {
                        replacement = replacement.Replace("/", "%2F").Replace(" ", "+");
                    }

                    if (modelSpec.isHere(params_full_url_encoding))
                    {
                        replacement = TemplatesMan.UrlEncodeFull(replacement);
                    }
                    else
                    if (modelSpec.isHere(aspnet_form_encoding))
                    {
                        replacement = TemplatesMan.AspnetUrlEncodeFull(replacement);
                    }

                    if (modelSpec.isHere(params_UTF_to_UTF25pref_encoding))
                    {
                        replacement = TemplatesMan.UTF_to_UTF25pref(replacement);
                    }


                    if (!modelSpec.isHere(no_encoding_conversion))
                    {
                        data = data.Replace(torepl, TemplatesMan.Kirill_to_UTF(replacement));
                    }
                    else
                    {
                        data = data.Replace(torepl, replacement);
                    }
                }
            }
            else
            {
                for (int i = 0; i < rl.listCou; i++)
                {
                    string replacement = t.V(string.IsNullOrEmpty(rl[i].body) ? rl[i].PartitionName.Trim(new char[] { '#' }) : rl[i].body);
                    replacement = replacement.Trim(new char[] { '"' });

                    if (!modelSpec.isHere(no_slash_conversion))
                    {
                        replacement = replacement.Replace("/", "%2F").Replace(" ", "+");
                    }

                    if (modelSpec.isHere(params_full_url_encoding))
                    {
                        replacement = TemplatesMan.UrlEncodeFull(replacement);
                    }

                    if (modelSpec.isHere(params_UTF_to_UTF25pref_encoding))
                    {
                        replacement = TemplatesMan.UTF_to_UTF25pref(replacement);
                    }

                    if (!modelSpec.isHere(no_encoding_conversion))
                    {
                        data = data.Replace(rl[i].PartitionName, TemplatesMan.Kirill_to_UTF(replacement));
                    }
                    else
                    {
                        data = data.Replace(rl[i].PartitionName, replacement);
                    }
                }
            }


            message.body          = data;
            message.PartitionKind = "";
            message.CopyArr(new opis());
        }
示例#3
0
        public override void Process(opis message)
        {
            if (hc == null)
            {
                hc = new httpClient();
            }

            hc.ClearAdditionHeaders();

            opis ex = modelSpec.Duplicate();

            instanse.ExecActionModelsList(ex);

            opis headerz = ex[Headers];

            for (int i = 0; i < headerz.listCou; i++)
            {
                if (!headerz[i].PartitionName.StartsWith("not header format"))
                {
                    hc.AddHeader(headerz[i].PartitionName + ":" + headerz[i].body);
                }
            }

            hc.AcceptAllCertificates = ex[AcceptAllCertificate][AcceptAllCertificate].isInitlze;
            hc.allowAutoRedrect      = ex.isHere(allowAutoRedrect);

            bool rez = false;

            instanse.ExecActionModel(ex[dataToPost], ex[dataToPost]);

            string data = ex.V(dataToPost);

            if (ex.V(post_data_encoding) == "Kirill_to_UTF")
            {
                data = TemplatesMan.Kirill_to_UTF(data);
            }

            if (ex.V(post_data_encoding) == "url_encode")
            {
                data = TemplatesMan.Url_encode(data);
            }

            //if (ex[ProxySettings].isInitlze)// PROXY
            hc.proxySettings = ex[ProxySettings].W();

            opis t = new opis();

            t["request"] = ex;

            if ((ex.isHere(POST) && string.IsNullOrEmpty(ex.V(POST))) ||
                (ex.isHere(GET) && string.IsNullOrEmpty(ex.V(GET))))
            {
                t[webResponceModel.Status].body = "fail";
                t.Vset("Error", "you pass empty url");
                SharedContextRoles.SetRole(t, ex.isHere(role) ? ex[role].body : "responce", sharedVal);
                return;
            }

            try
            {
                if (ex.isHere(POST))
                {
                    rez = hc.Post(ex.V(POST), data);
                }

                if (ex.isHere(GET))
                {
                    rez = hc.Get(ex.V(GET));
                }


                if (ex.isHere(DownloadResource))
                {
                    var fi = hc.DownloadData(ex.V(DownloadResource), ex[DownloadResource].V(upLoadFileSpecs.CompiledFilename));
                    rez = fi == null ? false : fi.Exists && fi.Length > 100;
                }

                if (ex.isHere(DownloadBytes))
                {
                    var fi = hc.DownloadBytes(ex.V(DownloadBytes));
                    rez = fi == null ? false : fi.Length > 0;
                    t[webResponceModel.responseData]["data"].bodyObject = fi;
                    t[webResponceModel.responseData].Vset("length", (fi == null ? 0 : fi.Length).ToString());
                }


                if (ex.isHere(UP_loadResource))
                {
                    t[webResponceModel.Status].body = hc.UploadData(ex.V(UP_loadResource), ex[UP_loadResource].V(upLoadFileSpecs.CompiledFilename));
                    SharedContextRoles.SetRole(t, ex.isHere(role) ? ex[role].body : "responce", sharedVal);
                    return;
                }

                if (ex.isHere(UP_loadResource_put))
                {
                    t[webResponceModel.Status].body = hc.UploadFilePut(ex.V(UP_loadResource_put), ex[UP_loadResource_put].V(upLoadFileSpecs.CompiledFilename));
                    SharedContextRoles.SetRole(t, ex.isHere(role) ? ex[role].body : "responce", sharedVal);
                    return;
                }
            }
            catch (NullReferenceException e)
            {
                t.Vset("internal error", e.Message);
            }


            t[webResponceModel.Status].body = rez.ToString();

            if (!string.IsNullOrEmpty(hc.RedirectLocation))
            {
                t.Vset("RedirectLocation", hc.RedirectLocation);
            }

            if (ex.isHere(DownloadResource))
            {
                t["filename"].body = ex[DownloadResource].V(upLoadFileSpecs.CompiledFilename);
            }
            //t.Vset(webResponceModel.responseData, hc.responseData);

            if (!ex.isHere(DownloadBytes) && !ex.isHere(DownloadResource))
            {
                t[webResponceModel.responseHeaders] = hc.responceHeaders;

                t.Vset(webResponceModel.responseData, hc.responseData.Replace("\n", " "));
                var NewCookies = hc.NewCookies;
                t.Vset(webResponceModel.NewCookies, NewCookies);

                #region NewCookies

                if (NewCookies != null)
                {
                    string[] cookarr = NewCookies.Split(';');
                    foreach (string s in cookarr)
                    {
                        //opis o = new opis();
                        int spi = s.IndexOf('=');
                        if (spi > 0)
                        {
                            string name = s.Substring(0, spi);
                            string val  = s.Substring(spi + 1);

                            //o.Vset(name, val);
                            t[webResponceModel.NewCookies].Vset(name.Trim(), val);;
                        }
                    }
                }

                #endregion

                if (hc.responseData != null &&
                    !hc.responseData.StartsWith("<!DOCTYPE html") &&
                    !hc.responseData.StartsWith("<") &&
                    hc.contentType != null &&
                    hc.contentType.Contains("application/json"))
                {
                    if (hc.responseData.Contains("\n"))
                    {
                        hc.responseData = hc.responseData.Replace('\n', ' ');
                    }

                    opis trtrt = new opis();
                    trtrt.JsonParce(hc.responseData);
                    t[webResponceModel.responseDataParsed]["jsonObj"] = trtrt;
                }
            }

            hc.responseData = null;


            SharedContextRoles.SetRole(t, ex.isHere(role) ? ex[role].body : "responce", sharedVal);
        }