idHTTP问题 ( 积分: 200 )

  • 主题发起人 主题发起人 Rover
  • 开始时间 开始时间
R

Rover

Unregistered / Unconfirmed
GUEST, unregistred user!
我程序代码如下:
var
URL: String;
T : TIdHTTP;
begin
Result := true;
T := TIdHTTP.Create(Application);
T.Request.ContentType:='application/x-www-form-urlencoded';
T.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Win32)';

URL := 'http://211.114.222.222/Smsclientinterface/send.asp?' +
'circle=aaa&pwd=bbb';
try
ReturnStr := T.Get(URL);
except
on e: Exception do
begin
Result := false;
ReturnStr := e.Message;
end;
end;
ReturnStr := '' + Returnstr;

end;


报错,返回:HTTP/1.1 400 Bad Request

大家看我哪里出问题了?
 
我程序代码如下:
var
URL: String;
T : TIdHTTP;
begin
Result := true;
T := TIdHTTP.Create(Application);
T.Request.ContentType:='application/x-www-form-urlencoded';
T.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Win32)';

URL := 'http://211.114.222.222/Smsclientinterface/send.asp?' +
'circle=aaa&pwd=bbb';
try
ReturnStr := T.Get(URL);
except
on e: Exception do
begin
Result := false;
ReturnStr := e.Message;
end;
end;
ReturnStr := '' + Returnstr;

end;


报错,返回:HTTP/1.1 400 Bad Request

大家看我哪里出问题了?
 
兄弟,本来这个url 就打不开,所以报错,属于正常啊!
function tFrmMain.DownLoadVG_File(URL: string): string;
var NMHTTP1: TNMHTTP;
//tmpMemo1: tmemo;
begin
result := '';
NMHTTP1 := TNMHTTP.Create(nil);
NMHTTP1.InputFileMode := FALSE;
NMHTTP1.OutputFileMode := FALSE;

NMHTTP1.ReportLevel := 1;

// If CheckBox1.Checked then
// Begin
// NMHTTP1.Proxy := Edit11.Text;
// NMHTTP1.ProxyPort := StrToInt(Edit12.Text);
// End;

with NMHTTP1.HeaderInfo do begin
Cookie := '';
LocalMailAddress := '';
LocalProgram := '';
Referer := '';
UserID := '';
Password := '';
end;
NMHTTP1.TimeOut := 100000;
try
try
NMHTTP1.Get(URL);
result := NMHTTP1.Body;
except
result := '';
end
finally
NMHTTP1.Free;
end;
end;
 
地址我写的假的,当然打不开了。
 
T.Request.ContentType:='application/x-www-form-urlencoded';
T.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Win32)';
把这两个去掉
 
你最好给出真实的地址
 
后退
顶部