+ -
当前位置:首页 → 问答吧 → delphi POST网页的时候提示“invalid argument to date encode”错误!

delphi POST网页的时候提示“invalid argument to date encode”错误!

时间:2011-08-10

来源:互联网

delphi POST网页的时候提示“invalid argument to date encode”错误!大家帮忙看看

下面这个是delphi的函数

Delphi(Pascal) code


function  TForm1.httpPost(postUrl:string;Params:TStrings):string;
var
  idhtp1:   TIdHTTP;
begin
  idhtp1:=   TidHTTp.create(self);
  idhtp1.AllowCookies:=True;
  //idhtp1.HTTPOptions:=[hoForceEncodeParams];
  idhtp1.ProtocolVersion:=pv1_1;
  idhtp1.Request.ContentType:='application/x-www-form-urlencoded';
  idhtp1.Request.CacheControl:='no-cache';
  idhtp1.Request.UserAgent:='Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1';
  idhtp1.Request.Accept:='text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
  idhtp1.Request.AcceptEncoding:='Accept-Encoding=gzip,deflate';
  idhtp1.Request.AcceptCharSet:='Accept-Charset=gb2312,utf-8;q=0.7,*;q=0.7';
  idhtp1.Request.Connection:='keep-alive';
  try
    result := idhtp1.Post(postUrl,Params);  //运行到这句的时候报错,报错后点击确定,再按下F9又正常返回了!!快疯了!汗!!!大家帮帮忙!
  except
    Result := 'error';
  end;
end;
快疯了!汗!!!大家帮帮忙!








作者: wlfbhdx   发布时间: 2011-08-10

你抓包看下.看看哪里有问题了!
看这句提示,应该是参数吧.
如果可以把整段代码发下.

作者: LoveMit   发布时间: 2011-08-10

delphi里面使用了 try except 也会在编译的时候报错?????

作者: wlfbhdx   发布时间: 2011-08-10

引用 2 楼 wlfbhdx 的回复:
delphi里面使用了 try except 也会在编译的时候报错?????



你应该是使用的断点调试吧!
调试的时候当然会报错误啊.
运行的时候如果使用了try...except...end;就不会了

作者: LoveMit   发布时间: 2011-08-10

在这里使用Try...Except.End;只是把错误隐藏了.
但是最终问题还是没解决啊.

作者: LoveMit   发布时间: 2011-08-10

这是一个抓包的程序吧?
应该是你抓取的Params值有问题
Post后面可以再加一个参数TMemoryStream类型,保存下载的文件看看。

作者: cq_mark   发布时间: 2011-08-10