Home > Back-end >  Post Indy9 simulation error HTTP 1.1 400 bad request
Post Indy9 simulation error HTTP 1.1 400 bad request

Time:10-08

Don't know how to return a responsibility, a parameter is normal, but the string is both an error 400.
Please help me solve the points can add thank you enough.
The parameters of the two transfer code:
 
Procedure TFrmMain. BtnLoginClick (Sender: TObject);
Var
ResParams: TStringStream;
PostParams: TStringList;
The begin
BtnLogin. Enabled:=False;
ResParams:=TStringStream. Create (");
PostParams:=TStringList. Create;
Try
MmLog. Lines. The Clear;
IdHTTP. Request. CacheControl:='no - cache;
IdHTTP. Request. Connection:='Keep - the Alive;
IdHTTP. Request. Accept:='text/HTML, application/XHTML + XML, application/XML. Q=0.9 */*; Q=0.8 ';
IdHTTP. Request. ContentType:='application/x - WWW - form - urlencoded';
IdHTTP. Request. AcceptCharSet:="utf-8";
IdHTTP. Request. AcceptEncoding:="utf-8";
IdHTTP. Request. AcceptLanguage:="utf-8";
IdHTTP. HandleRedirects:=True;//allow the redirection, because this site will happen redirect
IdHTTP. AllowCookies:=True;
IdHTTP. HTTPOptions:=[hoForceEncodeParams];
PostParams. The Clear;
PostParams. Add (' account=account ');
PostParams. Add (' password=password);//the annotation pass a parameter is no problem!!!!!! Strange,?
//postParams. Add (' url=/console/remote/');
ResParams. WriteString (");
IdHTTP. Request. Referer:='https://sunlogin.oray.com/passport/login? Lang=zh_CN ';//set up the route, this site requires
IdHTTP. Post (' https://sunlogin.oray.com/passport/login? Lang=zh_CN ', postParams resParams);
MmLog. Lines. The Add (Utf8ToAnsi (resParams DataString));
The finally
ResParams. Free;
PostParams. Free;
BtnLogin. Enabled:=True;
end;
end;

CodePudding user response:

Try IdHTTP. Request. UserAgent remove indy, I use the baidu, indy access is prohibited

CodePudding user response:

I'm sorry, didn't see you, please ignore my answer, help top

CodePudding user response:

 ask ace to help  

CodePudding user response:

After the second parameter will be added & amp; , try to change the

PostParams. Add (' account=account ');
PostParams. Add (' & amp; the password=password ");

CodePudding user response:

Also wrong and TStringList class don't need to add & amp; , the completion of the parameter, the following URL that parameter recovery, the lack of some important parameters in some complains,

CodePudding user response:

Well, how to solve? Methods with o!!!!!!

CodePudding user response:

Seems to be no problem, I use the delphi7 own indy test, no error
  • Related