用clientsocket发送http头请求

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 jinlangal 的 blog

procedure tform1.button2click(sender: tobject);
var httpstr:string;
begin
    cs1.active :=true;
    httpstr:='get http://www.paymesurf.com:80/surf3.php?usrid=607 http/1.1'+#13#10;
    httpstr:=httpstr+'accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*'+#13#10;
    httpstr:=httpstr+'accept-language: zh-cn'+#13#10;
    httpstr:=httpstr+'user-agent: mozilla/4.0 (compatible; msie 6.0; windows nt 5.0; myie2; .net clr 1.1.4322)'+#13#10;
    httpstr:=httpstr+'host: www.paymesurf.com'+#13#10;
    httpstr:=httpstr+'proxy-connection: keep-alive'+#13#10;
    httpstr:=httpstr+' ';
    memo1.lines.add(httpstr);
    cs1.socket.sendtext(httpstr);
end;

procedure tform1.cs1read(sender: tobject; socket: tcustomwinsocket);
var s:string;
    succ:boolean;
begin
 succ :=false;
 s:=socket.receivetext;
 memo1.lines.add(s);
 if  (pos('200',s)<>0) then    //返回信息:200 ok,表示发送成功
 begin
  statusbar1.simpletext:='成功!';
  cs1.active :=false;
  succ :=true;
 end else
 begin
  statusbar1.simpletext:='失败';
  cs1.active:=true;
  succ :=false;
 end;
end;

为什么没有反回数据呢。试了多次也不行。看来http头还真是难搞呀。

本文关键:用clientsocket发送http头请求
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top