mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-22 17:09:27 +02:00
* Patch from Luca Olivetti to allow to specify an address to which server must bind (bug ID 27892)
git-svn-id: trunk@30639 -
This commit is contained in:
parent
75ec4adcf9
commit
62e50ca506
@ -48,10 +48,12 @@ Type
|
|||||||
FOnRequestError: TRequestErrorHandler;
|
FOnRequestError: TRequestErrorHandler;
|
||||||
FServer: TEmbeddedHTTPServer;
|
FServer: TEmbeddedHTTPServer;
|
||||||
function GetAllowConnect: TConnectQuery;
|
function GetAllowConnect: TConnectQuery;
|
||||||
|
function GetAddress: string;
|
||||||
function GetPort: Word;
|
function GetPort: Word;
|
||||||
function GetQueueSize: Word;
|
function GetQueueSize: Word;
|
||||||
function GetThreaded: Boolean;
|
function GetThreaded: Boolean;
|
||||||
procedure SetOnAllowConnect(const AValue: TConnectQuery);
|
procedure SetOnAllowConnect(const AValue: TConnectQuery);
|
||||||
|
procedure SetAddress(const AValue: string);
|
||||||
procedure SetPort(const AValue: Word);
|
procedure SetPort(const AValue: Word);
|
||||||
procedure SetQueueSize(const AValue: Word);
|
procedure SetQueueSize(const AValue: Word);
|
||||||
procedure SetThreaded(const AValue: Boolean);
|
procedure SetThreaded(const AValue: Boolean);
|
||||||
@ -70,6 +72,8 @@ Type
|
|||||||
Procedure Terminate; override;
|
Procedure Terminate; override;
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
// Address to listen on.
|
||||||
|
Property Address : string Read GetAddress Write SetAddress;
|
||||||
// Port to listen on.
|
// Port to listen on.
|
||||||
Property Port : Word Read GetPort Write SetPort Default 80;
|
Property Port : Word Read GetPort Write SetPort Default 80;
|
||||||
// Max connections on queue (for Listen call)
|
// Max connections on queue (for Listen call)
|
||||||
@ -91,10 +95,12 @@ Type
|
|||||||
function GetLookupHostNames : Boolean;
|
function GetLookupHostNames : Boolean;
|
||||||
Procedure SetLookupHostnames(Avalue : Boolean);
|
Procedure SetLookupHostnames(Avalue : Boolean);
|
||||||
function GetAllowConnect: TConnectQuery;
|
function GetAllowConnect: TConnectQuery;
|
||||||
|
function GetAddress: String;
|
||||||
function GetPort: Word;
|
function GetPort: Word;
|
||||||
function GetQueueSize: Word;
|
function GetQueueSize: Word;
|
||||||
function GetThreaded: Boolean;
|
function GetThreaded: Boolean;
|
||||||
procedure SetOnAllowConnect(const AValue: TConnectQuery);
|
procedure SetOnAllowConnect(const AValue: TConnectQuery);
|
||||||
|
procedure SetAddress(const AValue: string);
|
||||||
procedure SetPort(const AValue: Word);
|
procedure SetPort(const AValue: Word);
|
||||||
procedure SetQueueSize(const AValue: Word);
|
procedure SetQueueSize(const AValue: Word);
|
||||||
procedure SetThreaded(const AValue: Boolean);
|
procedure SetThreaded(const AValue: Boolean);
|
||||||
@ -102,6 +108,7 @@ Type
|
|||||||
function InitializeWebHandler: TWebHandler; override;
|
function InitializeWebHandler: TWebHandler; override;
|
||||||
Function HTTPHandler : TFPHTTPServerHandler;
|
Function HTTPHandler : TFPHTTPServerHandler;
|
||||||
Public
|
Public
|
||||||
|
Property Address : string Read GetAddress Write SetAddress;
|
||||||
Property Port : Word Read GetPort Write SetPort Default 80;
|
Property Port : Word Read GetPort Write SetPort Default 80;
|
||||||
// Max connections on queue (for Listen call)
|
// Max connections on queue (for Listen call)
|
||||||
Property QueueSize : Word Read GetQueueSize Write SetQueueSize Default 5;
|
Property QueueSize : Word Read GetQueueSize Write SetQueueSize Default 5;
|
||||||
@ -153,6 +160,11 @@ begin
|
|||||||
Result:=HTTPHandler.OnAllowConnect;
|
Result:=HTTPHandler.OnAllowConnect;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomHTTPApplication.GetAddress: String;
|
||||||
|
begin
|
||||||
|
Result:=HTTPHandler.Address;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCustomHTTPApplication.GetPort: Word;
|
function TCustomHTTPApplication.GetPort: Word;
|
||||||
begin
|
begin
|
||||||
Result:=HTTPHandler.Port;
|
Result:=HTTPHandler.Port;
|
||||||
@ -173,6 +185,11 @@ begin
|
|||||||
HTTPHandler.OnAllowConnect:=AValue;
|
HTTPHandler.OnAllowConnect:=AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomHTTPApplication.SetAddress(const AValue: string);
|
||||||
|
begin
|
||||||
|
HTTPHandler.Address:=Avalue;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomHTTPApplication.SetPort(const AValue: Word);
|
procedure TCustomHTTPApplication.SetPort(const AValue: Word);
|
||||||
begin
|
begin
|
||||||
HTTPHandler.Port:=Avalue;
|
HTTPHandler.Port:=Avalue;
|
||||||
@ -245,6 +262,11 @@ begin
|
|||||||
Result:=FServer.OnAllowConnect;
|
Result:=FServer.OnAllowConnect;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TFPHTTPServerHandler.GetAddress: string;
|
||||||
|
begin
|
||||||
|
Result:=FServer.Address;
|
||||||
|
end;
|
||||||
|
|
||||||
function TFPHTTPServerHandler.GetPort: Word;
|
function TFPHTTPServerHandler.GetPort: Word;
|
||||||
begin
|
begin
|
||||||
Result:=FServer.Port;
|
Result:=FServer.Port;
|
||||||
@ -265,6 +287,11 @@ begin
|
|||||||
FServer.OnAllowConnect:=Avalue
|
FServer.OnAllowConnect:=Avalue
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TFPHTTPServerHandler.SetAddress(const AValue: string);
|
||||||
|
begin
|
||||||
|
FServer.Address:=AValue
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TFPHTTPServerHandler.SetPort(const AValue: Word);
|
procedure TFPHTTPServerHandler.SetPort(const AValue: Word);
|
||||||
begin
|
begin
|
||||||
FServer.Port:=Avalue
|
FServer.Port:=Avalue
|
||||||
|
@ -111,6 +111,7 @@ Type
|
|||||||
FOnAllowConnect: TConnectQuery;
|
FOnAllowConnect: TConnectQuery;
|
||||||
FOnRequest: THTTPServerRequestHandler;
|
FOnRequest: THTTPServerRequestHandler;
|
||||||
FOnRequestError: TRequestErrorHandler;
|
FOnRequestError: TRequestErrorHandler;
|
||||||
|
FAddress: string;
|
||||||
FPort: Word;
|
FPort: Word;
|
||||||
FQueueSize: Word;
|
FQueueSize: Word;
|
||||||
FServer : TInetServer;
|
FServer : TInetServer;
|
||||||
@ -122,6 +123,7 @@ Type
|
|||||||
function GetActive: Boolean;
|
function GetActive: Boolean;
|
||||||
procedure SetActive(const AValue: Boolean);
|
procedure SetActive(const AValue: Boolean);
|
||||||
procedure SetOnAllowConnect(const AValue: TConnectQuery);
|
procedure SetOnAllowConnect(const AValue: TConnectQuery);
|
||||||
|
procedure SetAddress(const AValue: string);
|
||||||
procedure SetPort(const AValue: Word);
|
procedure SetPort(const AValue: Word);
|
||||||
procedure SetQueueSize(const AValue: Word);
|
procedure SetQueueSize(const AValue: Word);
|
||||||
procedure SetThreaded(const AValue: Boolean);
|
procedure SetThreaded(const AValue: Boolean);
|
||||||
@ -164,6 +166,8 @@ Type
|
|||||||
protected
|
protected
|
||||||
// Set to true to start listening.
|
// Set to true to start listening.
|
||||||
Property Active : Boolean Read GetActive Write SetActive Default false;
|
Property Active : Boolean Read GetActive Write SetActive Default false;
|
||||||
|
// Address to listen on.
|
||||||
|
Property Address : string Read FAddress Write SetAddress;
|
||||||
// Port to listen on.
|
// Port to listen on.
|
||||||
Property Port : Word Read FPort Write SetPort Default 80;
|
Property Port : Word Read FPort Write SetPort Default 80;
|
||||||
// Max connections on queue (for Listen call)
|
// Max connections on queue (for Listen call)
|
||||||
@ -683,6 +687,13 @@ begin
|
|||||||
FOnAllowConnect:=AValue;
|
FOnAllowConnect:=AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TFPCustomHttpServer.SetAddress(const AValue: string);
|
||||||
|
begin
|
||||||
|
if FAddress=AValue then exit;
|
||||||
|
CheckInactive;
|
||||||
|
FAddress:=AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TFPCustomHttpServer.SetPort(const AValue: Word);
|
procedure TFPCustomHttpServer.SetPort(const AValue: Word);
|
||||||
begin
|
begin
|
||||||
if FPort=AValue then exit;
|
if FPort=AValue then exit;
|
||||||
@ -773,7 +784,10 @@ end;
|
|||||||
|
|
||||||
procedure TFPCustomHttpServer.CreateServerSocket;
|
procedure TFPCustomHttpServer.CreateServerSocket;
|
||||||
begin
|
begin
|
||||||
FServer:=TInetServer.Create(FPort);
|
if FAddress='' then
|
||||||
|
FServer:=TInetServer.Create(FPort)
|
||||||
|
else
|
||||||
|
FServer:=TInetServer.Create(FAddress,FPort);
|
||||||
FServer.MaxConnections:=-1;
|
FServer.MaxConnections:=-1;
|
||||||
FServer.OnConnectQuery:=OnAllowConnect;
|
FServer.OnConnectQuery:=OnAllowConnect;
|
||||||
FServer.OnConnect:=@DOConnect;
|
FServer.OnConnect:=@DOConnect;
|
||||||
|
Loading…
Reference in New Issue
Block a user