关于IDHTTP 的POST 返回值一直是空,大家帮我看看吧
这是我截获的数据:
POST /login/zh/?ref=https://www.battlenet.com.cn/account/management/&app=bam&cr=true HTTP/1.1
Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, */*
Referer: https://www.battlenet.com.cn/login/zh/?ref=https://www.battlenet.com.cn/account/management/&app=bam&cr=truehttps://www.battlenet.com.cn/login/zh/?ref=https://www.battlenet.com.cn/account/management/&app=bam&cr=true
Accept-Language: zh-cn
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 2.0.50727)
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Host: www.battlenet.com.cn
Content-Length: 64
Connection: Keep-Alive
Cache-Control: no-cache
accountName=htm161@163.com&password=haitaoma1980&persistLogin=on
我就是照着这个原样,在delphi7里写的,但什么反应也没有,返回都是空字符串,快愁死我了。。
下面是代码:
procedure TForm1.Button4Click(Sender: TObject);
var
Param:TStringList;
RStream:TMemoryStream;
mystr:TStringList;
FLogStr:string;
begin
IdHTTP2.Request.CustomHeaders.Clear;
IdHTTP2.Request.Accept := 'image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, */*' ;
IdHTTP2.Request.Referer := 'https://www.battlenet.com.cn/login/zh/?ref=https://www.battlenet.com.cn/account/management/&app=bam&cr=true';
IdHTTP2.Request.AcceptLanguage := 'zh-cn';
IdHTTP2.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 2.0.50727)';
IdHTTP2.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP2.Request.AcceptEncoding := 'gzip, deflate';
IdHTTP2.Request.Host := 'www.battlenet.com.cn';
IdHTTP2.Request.ContentLength := 64;
IdHTTP2.Request.Connection := 'Keep-Alive';
IdHTTP2.Request.CacheControl := 'no-cache';
Param:=TStringList.Create;
RStream:=TMemoryStream.Create;
Param.Add('accountName=htm161@163.com');
Param.Add('password=haitaoma1980');
Param.Add('persistLogin=on');
IdHTTP2.HTTPOptions:= IdHTTP2.HTTPOptions + [hoKeepOrigProtocol];
IdHTTP2.HTTPOptions := IdHTTP2.HTTPOptions - [hoForceEncodeParams]; //去掉自动编码
IdHTTP2.HandleRedirects := True;//允许自动跳转
IdHTTP2.Post('https://www.battlenet.com.cn/login/zh/?ref=https://www.battlenet.com.cn/account/management/&app=bam&cr=true', Param,RStream);
mystr := TStringList.Create;
mystr.LoadFromStream(RStream);
Memo1.Text := mystr.Text ;
RStream.Free;
end;
返回值一直是空,界面还有IdCookieManager1,IdSSLIOHandlerSocket1两个空间都与IDHTTP2相关联了,
大家给想个办法吧,有空的话,帮小弟我测试一下,都一个星期了,还是搞不定,郁闷。。。
delphi IDHTTP POST HTTPS
[解决办法]
IdHTTP2.Request.AcceptEncoding := 'identity';
[解决办法]
加上这句试试:
IDHTTP2.ProtocolVersion := pv1_1;