Var
SPostParameters: TStringStream;
SResponse: TStringStream;//TStream;
StrPost strTmpCookie, strTmpHtml strTmpValue: string;//strResult
I, iGridRow: Integer;
The begin
IdHTTP1. Request. SetHeaders;
IdHTTP1. Request. Accept:='*/*';
IdHTTP1. Request. AcceptEncoding:='gzip, deflate';
IdHTTP1. Request. AcceptLanguage:='useful - Hans - CN, useful - Hans; Q=0.5 ';
IdHTTP1. Request. Connection:='Keep - the Alive;
IdHTTP1. Request. ContentType:='application/x - WWW - form - urlencoded; Charset=utf-8 ';
IdHTTP1. Request. Host:='111.111.111.111:8999';
IdHTTP1. Request. Referer:='http://111.111.111.111:8088/wui/index.html';
IdHTTP1. Request. UserAgent:='AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/Edge/537.36 18.18363';
IdHTTP1. Request. CustomHeaders. Values [' cookies'] :=strCookie;
StrPost:='fromwhere=monitor& MenuIds=1% 2 c101 & amp; Createdateselect=0 & amp; Requestname=& amp; Workcode=& amp; Typeid=& amp; Workflowid=& amp; Createdatefrom=& amp; Createdateto=& amp; Creatertype=0 '+
'& amp; Ownerdepartmentid=& amp; Creatersubcompanyid=& amp; Requestlevel=& amp; Requestid=& amp; Nodetype=1 & amp; Unophrmid=& amp; GDZT=1 & amp; TSZT=& amp; Docids=& amp; Hrmids=& amp; Crmids=& amp; Proids=& amp; ';
SPostParameters:=TStringStream. Create (strPost);
SResponse:=TStringStream. Create (");
Try
IdHTTP1. Post (strIndexURL sPostParameters, sResponse);
Except,
Application. MessageBox (' IdHTTP frequent mistakes! 'and' wrong ', MB_OK + MB_ICONSTOP);
end;
Memo1. Lines. The Add (+ IdHTTP1. 'IdHTTP1. The ResponseText:' the ResponseText);
Memo1. Lines. The Add (' IdHTTP1. Response. The ResponseText: '+ IdHTTP1. Response. The ResponseText);
Memo1. Lines. The Add (' IdHTTP1. Response. RawHeaders. Text: '+ IdHTTP1. Response. RawHeaders. The Text).
Memo1. Lines. The Add (' IdHTTP1. Response. RawHeaders. Text: '+ IdHTTP1. Response. RawHeaders. The Text).
end;
In the body content of the HTTP response that can be seen in the debugger, how to implement in Delphi code,
CodePudding user response:
VarVBody: string;
VBody:=IdHTTP1. Post (strIndexURL sPostParameters);
Memo1. Lines. The Add (+ vBody your Body:).
In fact he's not the Body, but the returned HTTP page code, you should be an interface that is returned JSON data, so take a good,
You use sResponse take to also go, of course, only need to convert sResponse to string is what you need.
CodePudding user response:
Memo1. Lines. The Add (+ sResponse. 'your Body:' DataString);CodePudding user response:
SResponse. The size length to crawl to the size, but the use of sResponse. DataString take less than content, memo1. Line. The add () had a say hello? , after using Utf8ToAnsi is empty, a great god can give some directions again,Memo1. Lines. The Add (' last '+ strCookie);
Memo1. Lines. The Add (IntToStr (sResponse. Size));
Memo1. Lines. The Add (sResponse DataString);
CodePudding user response:
I have to put all the code you write out, with the two ways, the first is certainly can,CodePudding user response:
Just can't take it, on the memo is to say hello?Var
SResponse: TMemoryStream;
Try
IdHTTP1. Post (strIndexURL sPostParameters, sResponse);
Except,
Application. MessageBox (' IdHTTP frequent mistakes! 'and' wrong ', MB_OK + MB_ICONSTOP);
end;
SResponse. SaveToFile (' D: \ sResponse. TXT);
CodePudding user response:
Caught normal message, the request is no problem, the problem should be out in the code or the server to do the compression,1, the problem of coding test under this can change (code) :
Stream:=TStringStream. Create (' ', TEncoding UTF8);
2, if because the server returns compression, as quoted IdCompressorZLib this unit can be specific a little forgot, ever also the service side compression problems,