抓包数据怎么用IDHTTP实现啊。。我用DELPHI提交的数据跟抓包数据不一样

qtc26 2011-10-28 10:23:11
正确的抓包数据:
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
...全文
343 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
qtc26 2011-10-28
  • 打赏
  • 举报
回复
顶,帮解决啊。
qtc26 2011-10-28
  • 打赏
  • 举报
回复
谢谢你提醒。。我刚才比较了一下我伪造的COOKIE,发现我在后面多加了一个S,哎。。郁闷了我2天,竟然是因为这个原因。。悲催。。
sun_cathay 2011-10-28
  • 打赏
  • 举报
回复
没必要和抓的一模一样啊,关键是参数以及cookie

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧