我用delphi7中idhttp控件做一个自动登陆网页的程序。在post数据的时候总是出现一个“http1.1 /302 found”的错误。
代码如下:
  procedure TForm1.Button1Click(Sender: TObject);begin
  poststr := tstringlist.Create;
  poststr.add('username=XXXX');
  poststr.add('password=XXXX');
  poststr.add('utoLogin=true');
  poststr.add('ourl=http%3A%2F%2Fwww.56.com%2F%3F8401');
  idhttp1.HandleRedirects := true;
  str := idhttp1.post('http://XXXXX.com/php/urs.php', poststr);
  memo1.Text := system.UTF8Decode(str);
  poststr.Free;
end;
如果把idhttp1.HandleRedirects := false;就出现“http/1.1 404”错误。
同样抓包回来的数据用VB写的程序post的时候就没有问题,所以数据应该是没有问题的。

解决方案 »

  1.   

    Indy   currently   reverts   the   HTTP   version   to   1.0   in   a   call   to   the   Post   method.   This   occurs   because   some   HTTP   servers   do   not   respect   the   RFC   for   HTTP   1.1   to   the   full   extent   of   the   specification.   In   particular,   most   servers   do   not   send   or   expect   to   receive   the   100-Continue   HTTP   header.   Until   an   optimum   solution   that   does   NOT   break   the   RFC   is   discovered,   Indy   will   restrict   all   POSTS   to   version   HTTP   1.0   compliance.
    RT!