コード例 #1
0
        /*设置返回值*/
        public string setResponseBody(string response_ta_value, List<Para> paraValue_list, Session oSession, UserTabpage oPage)
        {
            string[] requestPar = null;

            oSession["ui-color"] = "brown";

            if (oPage.getRequestType_cb().Text == "GET")
            {
                string url = oSession.url;
                requestPar = url.Split(new char[2] { '?', '&' });
            }
            else if(oPage.getRequestType_cb().Text == "POST")
            {
                string url = oSession.GetRequestBodyAsString();
                requestPar = url.Split(new char[1] { '&' });
            }

            foreach (Para para in paraValue_list)
            {
                if (para.getParaTypeComboBox().Text == "读取")
                {
                    foreach (string ii in requestPar)
                    {
                        if (ii.Contains(para.getParaName()))
                        {
                            para.setParaValue(ii.ToString().Substring(ii.ToString().IndexOf("=") + 1));
                        }
                    }
                }
            }

            oPage.updatepPreview_response1();

            if(oPage.getCheckBox2().Checked)
            {
                oPage.getResponseTextBoxValue().Text += "|" + oPage.getPreviewTextbox().Text;
            }

            /*将大括号中符合规定的值替换*/
            Regex reg = new Regex(@"(?<={)[^{}]+(?=})");
            MatchCollection mc = reg.Matches(response_ta_value);

            if (paraValue_list.Count == 0)
            {
                foreach (Match m in mc)
                {
                    if (m.Value == "json")
                    {
                        response_ta_value = response_ta_value.Replace("{" + m.Value + "}", this.jsonTOurlencode(oPage.getPreviewTextbox().Text));
                    }
                    else if (m.Value == "sign")
                    {
                        response_ta_value = response_ta_value.Replace("{" + m.Value + "}", this.Sign(oPage.getSignValue_text().Text, paraValue_list, oPage));
                    }
                }
            }
            else
            {
                foreach (Match m in mc)
                {
                    foreach(Para para in paraValue_list)
                    {
                        if(m.Value == para.getParaName())
                        {
                            if (para.getParaTypeComboBox().Text == "MD5")
                            {
                                response_ta_value = response_ta_value.Replace("{" + m.Value + "}", this.Sign(para.getParaValue(), paraValue_list, oPage));
                            }
                            else
                            {
                                response_ta_value = response_ta_value.Replace("{" + m.Value + "}", para.getParaValue());
                            }
                        }
                        else if(m.Value == "json")
                        {
                            response_ta_value = response_ta_value.Replace("{" + m.Value + "}", this.jsonTOurlencode(oPage.getPreviewTextbox().Text));
                        }
                        else if(m.Value == "sign")
                        {
                            response_ta_value = response_ta_value.Replace("{" + m.Value + "}", this.Sign(oPage.getSignValue_text().Text, paraValue_list, oPage));
                        }
               	 	}
                }
            }

            return response_ta_value;
        }
コード例 #2
0
        public void updateRequest(UserTabpage oPage)
        {
            if (this.oSession.HTTPMethodIs("POST") && oPage.getRequestType_cb().Text == "POST" && this.oSession.uriContains(oPage.getUrlTextBox().Text) && this.oSession.GetRequestBodyAsString().Contains(oPage.getRequestbody_tb().Text))
            {
                oSession.utilSetRequestBody(this.setRequestBody(oSession.GetRequestBodyAsString(), oPage));

                string ori_url = oSession.url;
                string new_url = this.setRequestUrl(ori_url, oPage);
                oSession.url = new_url;

            }
            else if (this.oSession.HTTPMethodIs("GET") && oPage.getRequestType_cb().Text == "GET" && this.oSession.uriContains(oPage.getUrlTextBox().Text))
            {
                string ori_url = oSession.url;
                string new_url = this.setRequestUrl(ori_url, oPage);
                oSession.url = new_url;
            }
        }
コード例 #3
0
 /*更新返回值和json预览*/
 public void updateResponseBody(UserTabpage oPage)
 {
     if (this.oSession.HTTPMethodIs("POST") && oPage.getRequestType_cb().Text == "POST" && this.oSession.uriContains(oPage.getUrlTextBox().Text) && this.oSession.GetRequestBodyAsString().Contains(oPage.getRequestbody_tb().Text))
     {
         //oPage.updatepPreview_response1();
         oSession.utilSetResponseBody(setResponseBody(oPage.getResponseTextBoxValue().Text, oPage.getPara_list(), oSession, oPage));
     }
     else if (this.oSession.HTTPMethodIs("GET") && oPage.getRequestType_cb().Text == "GET" && this.oSession.uriContains(oPage.getUrlTextBox().Text))
     {
         //oPage.updatepPreview_response1();
         oSession.utilSetResponseBody(setResponseBody(oPage.getResponseTextBoxValue().Text, oPage.getPara_list(), oSession, oPage));
     }
 }