首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

抓包数据如何用IDHTTP实现啊小弟我用DELPHI提交的数据跟抓包数据不一样

2012-02-03 
抓包数据怎么用IDHTTP实现啊。。我用DELPHI提交的数据跟抓包数据不一样正确的抓包数据:POST /interface/reco

抓包数据怎么用IDHTTP实现啊。。我用DELPHI提交的数据跟抓包数据不一样
正确的抓包数据:
POST /interface/recordclick?random=0.6318651015230694 HTTP/1.1
x-requested-with: XMLHttpRequest
Accept-Language: zh-cn
Referer: http://ksfmf.qq.com/default/main
Accept: application/json, text/javascript, */*
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; InfoPath.2)
Host: ksfmf.qq.com
Content-Length: 7
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: pt2gguin=o2358028621; ptisp=cnc; show_id=; adid=2358028621; verifysession=h006a16bae8ee6b6bdb2538aec5e7ef41eca3ab5d7b92f332017836f76cc6dd3347302bfa78d4a37ede3961eb5135538830; ptui_loginuin=2358028621; uin=o2358028621; skey=@rA7lhCOI9

type=mb
我的DELPHI原码:
begin
  s1:=tstringlist.Create;
  response:=tstringstream.Create('');
  http.ReadTimeout := 30000;
  http.HandleRedirects := false;
  http.Port:=80;
  http.Request.AcceptEncoding:='gzip, deflate';
  http.HTTPOptions:=http.HTTPOptions+[hoKeepOrigProtocol];//关键这行
  http.ProtocolVersion:=pv1_1;
  http.Request.Accept := 'application/json, text/javascript, */*';
  http.Request.AcceptLanguage := 'zh-cn';
  http.Request.ContentType := 'application/x-www-form-urlencoded';
  http.Request.UserAgent :='Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Maxthon; InfoPath.2)';
  http.Request.Referer:='http://ksfmf.qq.com/default/main';
  http.Request.Host:='ksfmf.qq.com';
  http.Request.ContentLength:=7;
  http.Request.Connection:='Keep-Alive';
  http.Request.CacheControl:='no-cache';
  http.Request.SetHeaders; //最重要的初始化。
  http.Request.CustomHeaders.Add('x-requested-with:'+' XMLHttpRequest');
  for i:=0 to memo1.lines.Count-1 do
  begin
  str:=str+memo1.Lines[i];
  end;
  http.Request.CustomHeaders.Add('cookies:'+str);
  try
  s1.Add('type=mb');
  http.Post(edit1.Text,s1,response);
  memo2.lines.Add(http.Response.responsetext+#13#10+http.response.RawHeaders.text);
  memo2.lines.Add(response.datastring);//utf8toansi字符转换
  finally
  s1.Free;
  response.Free;
  end;
end;

但我发现我用DELPHI发现
1、无法控制HTTP头各参数的顺序,
2、http头和POST参数被分开了,返回结果也不对。
谢谢各位帮我解决这个问题啊。。
我的发包抓包数据1:
POST /interface/recordclick?random=0.6318651015230694 HTTP/1.1
Connection: Keep-Alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 7
Cache-control: no-cache
x-requested-with: XMLHttpRequest
cookies:pt2gguin=o2358028621; ptisp=cnc; show_id=; adid=2358028621; verifysession=h006a16bae8ee6b6bdb2538aec5e7ef41eca3ab5d7b92f332017836f76cc6dd3347302bfa78d4a37ede3961eb5135538830; ptui_loginuin=2358028621; uin=o2358028621; skey=@rA7lhCOI9
Host: ksfmf.qq.com
Accept: application/json, text/javascript, */*
Accept-Encoding: gzip, deflate
Accept-Language: zh-cn
Referer: http://ksfmf.qq.com/default/main
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Maxthon; InfoPath.2)

我的发包抓包数据2:
type=mb

[解决办法]
没必要和抓的一模一样啊,关键是参数以及cookie

热点排行