我在编写程序的时候出现了错误,代码如下:
procedure TForm1.Button1Click(Sender: TObject); var
temp_response:Tstringstream; temp:TStringList; begin
url:='http://localhost/login.asp';
try temp:=TStringList.Create; temp_response:=Tstringstream.Create(''); temp.Values['username']:=edit1.text; temp.Values['password']:=edit2.text;
try idhttp1.ProtocolVersion:=pv1_1; idHttp1.Request.ContentType := 'application/x-www-form-urlencoded'; idhttp1.post(url,temp,temp_response); temp.Free; temp_response.Free; except
memo1.text:=temp_response.datastring; temp.Free; exit; end;
except
temp_response.Free; exit; end;
end;
问题是假设我提交的参数有错误,memo1.text:=temp_response.datastring; 中没有内容. 要么就是接收的内容中只有一句."HTTP/1.1 500 Internal Server Error" 我的目的是想接收到网页错误信息,并对网页的错误信息进行过滤处理,在delphi中编好程序后运行用抓包工具得到其中一个包如下内容:
内容是这样的:
HTTP/1.1 500 Internal Server Error Connection: keep-alive Date: Thu, 06 Jul 2006 00:23:12 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET Content-Length: 347 Content-Type: text/html Cache-control: private
<font face="宋体" size=2><p>数据错误</font> <font face="宋体" size=2>
说明错误信息已经返回来了.我想把所有的错误都接收到,但是好像只能接收第一行的数据."HTTP/1.1 500 Internal Server Error",后面的数据被idhttp过滤到了.那么我如何才能把所有的错误信息都接收到并显示在memo1控件中呢?
|