【发布时间】:2015-12-22 12:44:11
【问题描述】:
如何正确发送这样的POST请求?
您可以在正确的位置看到所有线条。
如您所见,所有字符串都排成一行。
有我的代码(Delphi):
procedure TForm1.sButton1Click(Sender: TObject);
var
HTTP: TIdHTTP;
Data : TStringList;
l,p:string;
html:string;
begin
HTTP:=TIdHTTP.Create(self);
Data := TStringList.Create;
HTTP.HandleRedirects:=True;
HTTP.Request.Host:='192.168.0.111';
HTTP.Request.Connection:='keep-alive';
HTTP.Request.CacheControl:='max-age=0';
HTTP.Request.Accept:='text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8';
HTTP.Request.UserAgent:='Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36';
HTTP.Request.AcceptLanguage:='ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4';
//-----------
HTTP.Request.Referer:='http://192.168.0.111/';
HTTP.Request.CustomHeaders.Clear;
with HTTP.Request.CustomHeaders do
begin
AddValue('Cookie','Authorization=Basic YWRtaW46YWRtaW4=');
end;
http.Get('http://192.168.0.111/');
HTTP.Request.ContentType:='text/plain';
HTTP.Request.Accept:='text/plain';
Data.Add('[WAN_ETH_INTF#2,0,0,0,0,0#0,0,0,0,0,0]0,2');
Data.Add('enable');
Data.Add('X_TP_lastUsedIntf');
Data.Add('[WAN_IP_CONN#2,1,1,0,0,0#0,0,0,0,0,0]1,0');
Data.Add('[WAN_IP_CONN#2,1,2,0,0,0#0,0,0,0,0,0]2,0');
Data.Add('[WAN_PPP_CONN#2,1,1,0,0,0#0,0,0,0,0,0]3,0');
Data.Add('[WAN_IP6_CONN#2,1,1,0,0,0#0,0,0,0,0,0]4,0');
Data.Text:=URLDecode(Data.Text);
html:=HTTP.Post('http://192.168.0.111/cgi?1&1&1&1&1',Data);
sMemo1.Lines.Add(html);;
Data.Free;
FreeAndNil(HTTP);
end;
如何在我的情况下做出正确的反应?
【问题讨论】:
-
删除
Data.Text:=URLDecode(Data.Text);
标签: delphi delphi-xe2 delphi-xe