我下载了一个delphi写的程序 通过嗅探他的post按钮 结果如下:
POST /gb.asp HTTP/1.1
Accept: Accept: */*, /gb.asp, 127.0.0.1
Content-Type: application/x-www-form-urlencoded
User-Agent: MyApp
Host: 127.0.0.1
Content-Length: 77
Cache-Control: no-cacheserver=测试服务器&ck=留言成功&action=saveup&username=用户名&password=密码
post成功了.
然后我用idhttp进行post,嗅探结果如下:
POST /gb.asp HTTP/1.0
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 149
Host: 127.0.0.1
Accept: text/html, */*
User-Agent: Mozilla/3.0 (compatible; Indy Library)server=%B2%E2%CA%D4%B7%FE%CE%F1%C6%F7%26ck%3D%C1%F4%D1%D4%B3%C9%B9%A6%26action%3Dsaveup%26username%3D%D3%C3%BB%A7%C3%FB%26password%3D%C3%DC%C2%EBpost没有成功! 怎么连pos的内容都变了? 我用的组件有问题?他用什么组件?
POST /gb.asp HTTP/1.1
Accept: Accept: */*, /gb.asp, 127.0.0.1
Content-Type: application/x-www-form-urlencoded
User-Agent: MyApp
Host: 127.0.0.1
Content-Length: 77
Cache-Control: no-cacheserver=测试服务器&ck=留言成功&action=saveup&username=用户名&password=密码
post成功了.
然后我用idhttp进行post,嗅探结果如下:
POST /gb.asp HTTP/1.0
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 149
Host: 127.0.0.1
Accept: text/html, */*
User-Agent: Mozilla/3.0 (compatible; Indy Library)server=%B2%E2%CA%D4%B7%FE%CE%F1%C6%F7%26ck%3D%C1%F4%D1%D4%B3%C9%B9%A6%26action%3Dsaveup%26username%3D%D3%C3%BB%A7%C3%FB%26password%3D%C3%DC%C2%EBpost没有成功! 怎么连pos的内容都变了? 我用的组件有问题?他用什么组件?
_HTTP : TIDHTTP;
TempStr : TStrings;
begin
_HTTP := TIDHTTP.Create(Form1);
TempStr := TStringList.Create;
_HTTP.HandleRedirects := True;
_HTTP.Request.Accept := '*/*, /gb.asp, 127.0.0.1';
_HTTP.Request.ContentType := 'application/x-www-form-urlencoded';
_HTTP.Request.UserAgent := 'MyApp';
_HTTP.Request.CacheControl := 'no-cache';
try
TempStr.Add('server=测试服务器');
TempStr.Add('ck=留言成功');
TempStr.Add('action=saveup');
TempStr.Add('username=用户名');
TempStr.Add('password=密码');
_HTTP.Post('http://localhost/gb.asp',TempStr);
except
Messagebox(0,'POST数据出错','提示',mb_OK);
end;
end;
_HTTP : TIDHTTP;
TempStr : TStrings;
begin
_HTTP := TIDHTTP.Create(Form1);
TempStr := TStringList.Create;
_HTTP.HandleRedirects := True;
_HTTP.Request.Accept := '*/*, /gb.asp, 127.0.0.1';
_HTTP.Request.ContentType := 'application/x-www-form-urlencoded';
_HTTP.Request.UserAgent := 'MyApp';
_HTTP.Request.CacheControl := 'no-cache';
try
TempStr.Clear;
TempStr.Add('server=测试服务器');
TempStr.Add('ck=留言成功');
TempStr.Add('action=saveup');
TempStr.Add('username=用户名');
TempStr.Add('password=密码');
_HTTP.Connected;
_HTTP.Post('http://localhost/gb.asp',TempStr);
except
Messagebox(0,'POST数据出错','提示',mb_OK);
end;
_HTTP.Disconnect;
_HTTP.Free;
TempStr.Free;
end;
sniffer结果如下 POST /gb.asp HTTP/1.0
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 134
Cache-control: no-cache
Host: 127.0.0.1
Accept: */*, /gb.asp, 127.0.0.1
User-Agent: MyAppserver=%B2%E2%CA%D4%B7%FE%CE%F1%C6%F7%26ck%3D%C1%F4%D1%D4%B3%C9%B9%A6%26action%3Dsaveup%26username%3D%D3%C3%BB%A7%C3%FB%26password%3D%C3%DC%C2%EB
url还是编码了 难道控件用错了? HTTP/1.0也没有变成http/1.1,我想这是关键点
begin
ShowMessage(HTTPEncode('测试服务器'));end;
HTTPEncode 函数
他的 http/1.1 User-Agent: MyApp url未编码 (我不觉得是他写函数实现)
我的是 HTTP/1.0 User-Agent: Mozilla/3.0 url编码
难道post 数据还有几个控件??
他的url未编码 (我不觉得是他写函数实现,控件默认就是未编码)