请大虾出招,感谢
PROCEDURE TForm1.Button1Click(Sender: TObject);
VAR
myParams: TStringList;
ret: TStringStream;
PostDataStream: TStringStream;
ParamData: TStringStream;
i: integer;
sXML: TStringList;
sText: STRING;
BEGIN
IdHTTP1.ReadTimeout := 10 * 1000; //设置超时时间10seconds
IdHttp1.Request.ContentType := 'application/x-www-form-urlencoded';
idhttp1.ProxyParams.ProxyPort := 2000;
idhttp1.Request.Host := '211.94.133.90';
idhttp1.Request.ContentLength := 959;
IdHTTP1.Request.Accept := 'text/html, */*';
idhttp1.Request.AcceptLanguage := 'en-us';
idhttp1.Request.AcceptEncoding := 'gzip,deflate';
idhttp1.Request.Connection := 'Keep-Alive';
idhttp1.Request.AcceptCharSet := 'ISO-8859-1';
idhttp1.Request.UserAgent :=
'Mozilla/4.0(compatible;MSIE 5.01;Windows NT 5.0;DigExt)';
IdHttp1.HTTPOptions := [hoForceEncodeParams];
ret := tstringstream.Create('');
myParams := tstringlist.Create;
TRY
PostDataStream := TStringStream.Create('');
ParamData := TStringStream.Create('');
sXML := TStringList.Create;
sXML.LoadFromFile('../demo.xml');
sText := sXML.Text;
FINALLY
sXML.Free;
END;
TRY
IdHTTP1.Request.CustomHeaders.Text := sText;
ParamData := TStringStream.Create('');
idhttp1.Post('http://211.94.133.90/LcsInterface', ParamData, ret);
showmessage(ret.DataString); //返回页面源码
showmessage(idhttp1.ResponseText); //返回错误信息
//memo2.Lines.Add('请求成功!');
memo2.Lines.Add(ret.DataString);
EXCEPT
//memo2.Lines.Add('请求失败!');
Label1.Caption := '请重新请求......';
myParams.Free;
ParamData.Free;
END;
idhttp1.Disconnect;
FreeAndNil(idhttp1);
freeAndNil(myparams);
Ret.Position := 0;
memo1.Lines.LoadFromStream(ret);
ret.Free;
form1.Refresh;
END;
XML文件请求内容如下:
POST http://211.94.133.90/a.lif HTTP/1.1
Host: 211.94.133.90
Content-Length: 959
Content-Type:text/xml
<html>
<Envelope>
<body>
<?xml version="1.0" encoding="GB2312"?>
<!DOCTYPE REQ SYSTEM "LOCREQ.DTD">
<REQ>
</REQ>
</body>
</Envelope>
以上是请求的代码,请求后返回信息如下,不知问题出在哪里,请指教,谢谢!
Socket Error #10054
Connection reset by peer;