How to send two to modify the Body Request

我的未来我决定 提交于 2020-01-23 17:29:07

问题


I'm running into a small roadblock. English is poor, difficulty in expressing

I want to modify the Request in the body and sent two consecutive Request

Original content:

POST http://www.text.com/next?cyt=1 is
HTTP/1.1
Host: www.text.com
User-Agent: Million/1.0.0
Content-Length: 58
Accept: * / *
Accept-Encoding: gzip
Accept-Language:
Content-Type: application / x-www-form-urlencoded
Cookie: S = hveisf76n2lrnpvbeng8ivrat6
Connection: keep-alive
Connection: keep-alive

S = hveisf76n2lrnpvbeng8ivrat6 & step = ashf87afs0a2e4

An attempt was made ​​to modify the Body and send to:

S = hveisf76n2lrnpvbeng8ivrat6 & step = qarker11s77ar

Another attempt to modify the Body and send to:

S = hveisf76n2lrnpvbeng8ivrat6 & step = qarker22s88ar

Request sent twice modified body

I try to do the code:


 static function OnBeforeRequest(oSession: Session) 
{ 
   if(oSession.uriContains("http://www.text.com/next?cyt=1"))
   {
      var strBody=oSession.GetRequestBodyAsString();                                                    
      strBody=strBody.replace("step=ashf87afs0a2e4","step=qarker11s77ar");
      oSession.utilSetRequestBody(strBody);

         var strBody1=oSession.GetRequestBodyAsString();
         strBody1=strBody.replace("step=qarker11s77ar","step=qarker22s88ar");
         oSession.utilSetRequestBody(strBody1);
   }
}

 

The question that arises is:

S = hveisf76n2lrnpvbeng8ivrat6 & step = qarker11s77ar

Successful transmission, but

S = hveisf76n2lrnpvbeng8ivrat6 & step = qarker22s88ar

And can not be sent, how to solve this problem? Thank you.


回答1:


static function OnBeforeRequest(oSession: Session) 
{ 
if(oSession.uriContains("http://www.text.com/next?cyt=1"))
{
var strBody=oSession.GetRequestBodyAsString();                                                    
  strBody=strBody.replace("step=ashf87afs0a2e4","step=qarker11s77ar");
  strBody=strBody.replace("step=qarker11s77ar","step=qarker22s88ar");
     oSession.utilSetRequestBody(strBody);
}
}


来源:https://stackoverflow.com/questions/15863044/how-to-send-two-to-modify-the-body-request

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!