为什么发不了帖呢,返回 HTTP/1.0 200 OK
为什么返回的版本是1.0呢procedure TForm1.Post;
const
BaseURL = 'http://bbs.it.com.cn/'; //地址
var
IdHTTP: TIdHTTP;
Params: TStrings;
HTML: String;
begin
idHTTP:= TidHTTp.create(self);
Params := TStringList.Create;
IdHTTP.AllowCookies := true;
IdHTTP.HTTPOptions:=[hoForceEncodeParams];
IdHTTP.ProtocolVersion := pv1_1;
IDHTTP.Request.Accept:='*/*';
IdHTTP.Request.Referer:='http://bbs.it.com.cn/ShowPost.aspx?TopicID=68696';
IdHTTP.Request.AcceptLanguage := 'zh-cn';
IdHTTP.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP.Request.AcceptEncoding := 'gzip, deflate';
IdHTTP.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; Alexa Toolbar; 56flvplayer 1.0)';
IdHTTP.Request.Host := 'bbs.it.com.cn';
IdHTTP.Request.ContentLength := length(Edit1.Text);
IdHTTP.Request.Connection := 'Keep-Alive';
IdHTTP.Request.CacheControl := 'no-cache';
Params.Add('message='+Edit1.Text);
try
HTML:=IdHttp.Post(BaseURL+'ShowPost.aspx?TopicID=68696',Params);
except
showmessage('error');
exit;
end;
Memo1.Text := IdHttp.ResponseText;
IdHTTP.Disconnect;
FreeAndNil(IdHTTP);
FreeAndNil(Params);
end;
为什么返回的版本是1.0呢procedure TForm1.Post;
const
BaseURL = 'http://bbs.it.com.cn/'; //地址
var
IdHTTP: TIdHTTP;
Params: TStrings;
HTML: String;
begin
idHTTP:= TidHTTp.create(self);
Params := TStringList.Create;
IdHTTP.AllowCookies := true;
IdHTTP.HTTPOptions:=[hoForceEncodeParams];
IdHTTP.ProtocolVersion := pv1_1;
IDHTTP.Request.Accept:='*/*';
IdHTTP.Request.Referer:='http://bbs.it.com.cn/ShowPost.aspx?TopicID=68696';
IdHTTP.Request.AcceptLanguage := 'zh-cn';
IdHTTP.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP.Request.AcceptEncoding := 'gzip, deflate';
IdHTTP.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; Alexa Toolbar; 56flvplayer 1.0)';
IdHTTP.Request.Host := 'bbs.it.com.cn';
IdHTTP.Request.ContentLength := length(Edit1.Text);
IdHTTP.Request.Connection := 'Keep-Alive';
IdHTTP.Request.CacheControl := 'no-cache';
Params.Add('message='+Edit1.Text);
try
HTML:=IdHttp.Post(BaseURL+'ShowPost.aspx?TopicID=68696',Params);
except
showmessage('error');
exit;
end;
Memo1.Text := IdHttp.ResponseText;
IdHTTP.Disconnect;
FreeAndNil(IdHTTP);
FreeAndNil(Params);
end;
第一 length 严重不符合Params.Add('message='+Edit1.Text);
IdHTTP.Request.ContentLength := length(Edit1.Text);第二,建议使用 流
aStream: TMemoeyStream; 代替 Params: TStrings;
Params.Add('PostBackClick="提 交"');
http://home.fego.cn/members/sys/m_Blog/Detail.aspx?id=2504
Params.WriteString('font=&');
Params.WriteString('size=&');
Params.WriteString('color=&');
Params.WriteString('message='+HttpEncode(Edit1.Text)+'&');
Params.WriteString('PostBackClick='+HttpEncode('提 交'));
__VIEWSTATE=dDwxMjczMDI1ODE4Ozs%2BHRda3TWXz%2F%2FWly6ZPcs0cvXeXkA%3D&font=&size=&color=&message=%B9%FE%B9%FE%B9%FE%B9%FE&PostBackClick=%CC%E1++++%BD%BB
用httplook软件抓到的是 HTTP/1.0 500 Internal Server Error
直接看返回的数据对不对
Accept: */*
Referer: http://bbs.it.com.cn/ShowPost.aspx?TopicID=68696
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; Alexa Toolbar; 56flvplayer 1.0)
Host: bbs.it.com.cn
Content-Length: 151
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: __utma=232739911.1869291454.1052835898.1052835898.1052837372.2; __utmb=232739911; __utmz=232739911.1052835898.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none); __utmc=232739911; ASP.NET_SessionId=r4ro1w45mlux5rfrtna41q45; popped=yes__VIEWSTATE=dDwxMjczMDI1ODE4Ozs%2BHRda3TWXz%2F%2FWly6ZPcs0cvXeXkA%3D&font=&size=&color=&message=%B9%FE%B9%FE%B9%FE%B9%FE&PostBackClick=%CC%E1++++%BD%BB
现在提交返回:HTTP/1.0 302 Moved Temporarily 这个了~
POST /ShowPost.aspx?TopicID=68696 HTTP/1.1
这里应该还是HTTP/1.0
if not IdHTTP1.Response.ResponseCode=302 then
showmessage('error');
exit;
end;