请问大家有没有使用过,或者是自己写过能够自定义http报头信息的网页浏览器?(226分)

  • 主题发起人 主题发起人 lailongmen
  • 开始时间 开始时间
L

lailongmen

Unregistered / Unconfirmed
GUEST, unregistred user!
有的话能给我一个吗? 或者告诉我哪里有下载?
谢谢大家了.我全部的分都在这里.
 
最简单范例。
分你自己留着吧。

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ScktComp;

type
TForm1 = class(TForm)
ServerSocket: TServerSocket;
btnStart: TButton;
btnStop: TButton;
procedure btnStartClick(Sender: TObject);
procedure btnStopClick(Sender: TObject);
procedure ServerSocketClientRead(Sender: TObject;
Socket: TCustomWinSocket);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.btnStartClick(Sender: TObject);
begin
ServerSocket.Open;
end;

procedure TForm1.btnStopClick(Sender: TObject);
begin
ServerSocket.Close;
end;

procedure TForm1.ServerSocketClientRead(Sender: TObject;
Socket: TCustomWinSocket);
Var
s,rep:String;
i,j:Byte;
begin
rep:='<html><body><font face="宋体" size="小五" color="red">Well Done!正常</font><br>No page found<br></body></html>';

s:=Socket.ReceiveText;
For i:=1 to Length(s) do s:=UpCase(s);
If Copy(s,1,3)='GET' Then
Begin
Socket.SendText('HTTP/1.1 200 OK'#$0D#$0A);
Socket.SendText('MIME-version: 1.0'#$0D#$0A);
Socket.SendText('Content-Length: '+InttoStr(Length(rep))+#$0D#$0A);
Socket.SendText('Content-Type: text/html'#$0D#$0A);
Socket.SendText(#$0D#$0A);
for j:=1 to length(rep) do
begin
Socket.SendText(rep[j]);
//sleep(500);
end;

Socket.Close;
End;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
If ServerSocket.Active Then ServerSocket.Close;
end;

end.
 
接受答案了.
 
后退
顶部