打印本文 打印本文 关闭窗口 关闭窗口
TCP/IP (四)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1944  更新时间:2009/4/23 18:43:56  文章录入:mintao  责任编辑:mintao
; ok,ok2:integer;
  proto,user,pass,host,port,path: string;
begin
(*@///   parse url and proxy to f_hostname, f_path and f_socket_number *)
if f_proxy<>'''''''' then begin
  parse_url(f_proxy,proto,user,pass,host,port,path);
  f_path:=f_url;
  if port='''''''' then port:=''''8080'''';
  end
else begin
  parse_url(f_url,proto,user,pass,host,port,f_path);
  if port='''''''' then port:=''''80'''';
  end;
if proto='''''''' then  proto:=''''http'''';
if path='''''''' then path:=''''/'''';

f_hostname:=host;
f_Socket_number:=strtoint(port);
(*@\\\*)
  login;
  sendrequest(''''POST'''',''''1.0'''');
(*@///   Send the data *)
TMemorystream(f_stream).seek(0,0);
ok:=1;
while ok>0 do begin
  ok:=f_stream.read(f_buffer^,buf_size);
  write_buf(f_socket,f_buffer^,ok);
  end;
(*@\\\0000000607*)
  getanswer;
(*@///   read in the response body *)
TMemorystream(f_stream).clear;
while not eof(f_socket) do begin
  read_var(f_socket,f_buffer^,buf_size,ok);
  p:=f_buffer;
  while ok>0 do begin   (* just to be sure everything goes into the stream *)
    ok2:=f_stream.write(p^,ok);
    dec(ok,ok2);
    p:=pointer(longint(p)+ok2);
    end;
  end;
f_stream.seek(0,0);  (* set the stream back to start *)
(*@\\\0000000201*)
  logout;
  end;

上一页  [1] [2] 

打印本文 打印本文 关闭窗口 关闭窗口