線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2247
推到 Plurk!
推到 Facebook!

关于idhttp.post 错误处理问题

 
dragon1000
一般會員


發表:10
回覆:6
積分:3
註冊:2006-07-06

發送簡訊給我
#1 引用回覆 回覆 發表時間:2006-07-06 08:39:27 IP:61.167.xxx.xxx 未訂閱

我在编写程序的时候出现了错误,代码如下:

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


数据错误

说明错误信息已经返回来了.我想把所有的错误都接收到,但是好像只能接收第一行的数据."HTTP/1.1 500 Internal Server Error",后面的数据被idhttp过滤到了.那么我如何才能把所有的错误信息都接收到并显示在memo1控件中呢?

dragon1000
一般會員


發表:10
回覆:6
積分:3
註冊:2006-07-06

發送簡訊給我
#2 引用回覆 回覆 發表時間:2006-07-06 08:46:00 IP:61.167.xxx.xxx 未訂閱

内容是这样的:

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>

dragon1000
一般會員


發表:10
回覆:6
積分:3
註冊:2006-07-06

發送簡訊給我
#3 引用回覆 回覆 發表時間:2006-07-06 09:05:44 IP:61.167.xxx.xxx 未訂閱
麻烦斑竹请移到delphi区,我发错了
系統時間:2024-04-24 8:23:47
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!