Skip to content

Commit

Permalink
use port 8080
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelJustin committed May 26, 2024
1 parent 24a7164 commit 07733b6
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion demo/00_bootstrap/BootstrapDemoMain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ procedure Demo;
begin
ConfigureLogging;

Server := TdjServer.Create(8080);
Server := TdjServer.Create;
try
// add a handlerlist with a TdjDefaultHandler
DefaultHandler := TdjDefaultHandler.Create;
Expand Down
4 changes: 2 additions & 2 deletions demo/01_helloworld/MainUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ procedure Demo;
Server: TdjServer;
Context: TdjWebAppContext;
begin
Server := TdjServer.Create(80);
Server := TdjServer.Create;
try
Context := TdjWebAppContext.Create('tutorial');
Context.AddWebComponent(THelloWorldResource, '/hello');
Server.Add(Context);
Server.Start;
WriteLn('Server is running, please open http://localhost/tutorial/hello');
WriteLn('Server is running, please open http://localhost:8080/tutorial/hello');
WriteLn('Hit enter to terminate.');
ReadLn;
finally
Expand Down
4 changes: 2 additions & 2 deletions demo/02_sessions/MainUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ procedure Demo;
Server: TdjServer;
Context: TdjWebAppContext;
begin
Server := TdjServer.Create(80);
Server := TdjServer.Create;
try
Context := TdjWebAppContext.Create('tutorial', True);
Context.AddWebComponent(TSessionDemoResource, '/session');
Server.Add(Context);
Server.Start;
WriteLn('Server is running, please open http://localhost/tutorial/session');
WriteLn('Server is running, please open http://localhost:8080/tutorial/session');
WriteLn('Hit enter to terminate.');
ReadLn;
finally
Expand Down
4 changes: 2 additions & 2 deletions demo/03_mappings/MainUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ procedure Demo;
Server: TdjServer;
Context: TdjWebAppContext;
begin
Server := TdjServer.Create(80);
Server := TdjServer.Create;
try
Context := TdjWebAppContext.Create('tutorial');
Context.AddWebComponent(TFibonacciResource, '/fib.txt');
Context.AddWebComponent(TFibonacciResource, '/fib.html');
Server.Add(Context);
Server.Start;
WriteLn('Server is running, please open http://localhost/tutorial/fib.html?n=4 or http://localhost/tutorial/fib.txt?n=4');
WriteLn('Server is running, please open http://localhost:8080/tutorial/fib.html?n=4 or http://localhost:8080/tutorial/fib.txt?n=4');
WriteLn('Hit enter to terminate.');
ReadLn;
finally
Expand Down
2 changes: 1 addition & 1 deletion demo/05_formlogin/MainUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ procedure Demo;
Server: TdjServer;
Context: TdjWebAppContext;
begin
Server := TdjServer.Create(80);
Server := TdjServer.Create(80); // configured for port 80
try
Context := TdjWebAppContext.Create('', True);
Context.AddWebComponent(TLoginResource, '/index.html');
Expand Down
2 changes: 1 addition & 1 deletion source/djServer.pas
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface
Generics.Collections;

const
DEFAULT_BINDING_PORT = 80;
DEFAULT_BINDING_PORT = 8080;
DEFAULT_BINDING_IP = '127.0.0.1'; // instead of '0.0.0.0';

(**
Expand Down
8 changes: 4 additions & 4 deletions test/unittests/ConfigAPITests.pas
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ procedure TAPIConfigTests.TestIPv6ConnectionToLoopback;
Server.Add(Context);
Server.Start;

CheckGETResponseEquals('example', 'http://[::1]/example/index.html');
CheckGETResponseEquals('example', 'http://[::1]:8080/example/index.html');

finally
Server.Free;
Expand Down Expand Up @@ -897,7 +897,7 @@ procedure TAPIConfigTests.TestAddConnector;
Connector := TdjHTTPConnector.Create(Server.Handler);
// TODO DOC not TdjHTTPConnector.Create(Server)!
Connector.Host := '127.0.0.1';
Connector.Port := 80;
Connector.Port := 8080;
// new property "HTTPServer" in 1.5
// here used to set a file based logger for the HTTP server
Connector.HTTPServer.Intercept := Intercept;
Expand Down Expand Up @@ -931,7 +931,7 @@ procedure TAPIConfigTests.TestThreadPool;
Connector := TdjHTTPConnector.Create(Server.Handler);
// TODO DOC not TdjHTTPConnector.Create(Server)!
Connector.Host := '127.0.0.1';
Connector.Port := 80;
Connector.Port := 8080;
SchedulerOfThreadPool := TIdSchedulerOfThreadPool.Create(Connector.HTTPServer);
SchedulerOfThreadPool.PoolSize := 20;
// set thread pool scheduler
Expand Down Expand Up @@ -999,7 +999,7 @@ procedure TAPIConfigTests.TestContextWithConnectorName;
Server := TdjServer.Create;
try
Server.AddConnector('127.0.0.1', 8181);
Server.AddConnector('127.0.0.1', 80);
Server.AddConnector('127.0.0.1', 8080);
Server.AddConnector('127.0.0.1', 8282); // unused, just to see the order
// configure for context on standard port
ContextPublic := TdjWebAppContext.Create('public');
Expand Down
23 changes: 13 additions & 10 deletions test/unittests/HTTPTestCase.pas
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,16 @@ implementation
uses
Classes;

resourcestring
StrHttp127001 = 'http://127.0.0.1:8080';

{ THTTPTestCase }

procedure THTTPTestCase.CheckGETResponseEquals(Expected: string; URL: string = ''; msg: string = '');
var
Actual: string;
begin
if Pos('http', URL) <> 1 then URL := 'http://127.0.0.1' + URL;
if Pos('http', URL) <> 1 then URL := StrHttp127001 + URL;

Actual := IdHTTP.Get(URL{$IFDEF STRING_IS_ANSI}, DestEncoding{$ENDIF});

Expand All @@ -102,7 +105,7 @@ procedure THTTPTestCase.CheckCachedGETResponseEquals(IfModifiedSince: TDateTime;
var
Actual: string;
begin
if Pos('http', URL) <> 1 then URL := 'http://127.0.0.1' + URL;
if Pos('http', URL) <> 1 then URL := StrHttp127001 + URL;

IdHTTP.Request.RawHeaders.Values['If-Modified-Since'] := LocalDateTimeToGMT(IfModifiedSince);
Actual := IdHTTP.Get(URL{$IFDEF STRING_IS_ANSI}, DestEncoding{$ENDIF});
Expand All @@ -114,7 +117,7 @@ procedure THTTPTestCase.CheckCachedGETResponseIs304(IfModifiedSince: TDateTime;
var
Actual: Integer;
begin
if Pos('http', URL) <> 1 then URL := 'http://127.0.0.1' + URL;
if Pos('http', URL) <> 1 then URL := StrHttp127001 + URL;

IdHTTP.Request.LastModified := IfModifiedSince;
IdHTTP.HTTPOptions := IdHTTP.HTTPOptions + [hoNoProtocolErrorException];
Expand All @@ -128,39 +131,39 @@ procedure THTTPTestCase.CheckCachedGETResponseIs304(IfModifiedSince: TDateTime;
procedure THTTPTestCase.CheckContentTypeEquals(Expected: string; URL: string;
msg: string);
begin
if Pos('http', URL) <> 1 then URL := 'http://127.0.0.1' + URL;
if Pos('http', URL) <> 1 then URL := StrHttp127001 + URL;

IdHTTP.Get(URL);
CheckEquals(Expected, IdHTTP.Response.ContentType, msg);
end;

procedure THTTPTestCase.CheckGETResponse200(URL: string; msg: string);
begin
if Pos('http', URL) <> 1 then URL := 'http://127.0.0.1' + URL;
if Pos('http', URL) <> 1 then URL := StrHttp127001 + URL;

IdHTTP.Get(URL);
CheckEquals(200, IdHTTP.ResponseCode, msg);
end;

procedure THTTPTestCase.CheckGETResponse404(URL: string; msg: string);
begin
if Pos('http', URL) <> 1 then URL := 'http://127.0.0.1' + URL;
if Pos('http', URL) <> 1 then URL := StrHttp127001 + URL;

IdHTTP.Get(URL, [404]);
CheckEquals(404, IdHTTP.ResponseCode, msg);
end;

procedure THTTPTestCase.CheckGETResponse405(URL: string; msg: string);
begin
if Pos('http', URL) <> 1 then URL := 'http://127.0.0.1' + URL;
if Pos('http', URL) <> 1 then URL := StrHttp127001 + URL;

IdHTTP.Get(URL, [405]);
CheckEquals(405, IdHTTP.ResponseCode, msg);
end;

procedure THTTPTestCase.CheckGETResponse500(URL: string; msg: string);
begin
if Pos('http', URL) <> 1 then URL := 'http://127.0.0.1' + URL;
if Pos('http', URL) <> 1 then URL := StrHttp127001 + URL;

IdHTTP.Get(URL, [500]);
CheckEquals(500, IdHTTP.ResponseCode, msg);
Expand All @@ -170,7 +173,7 @@ procedure THTTPTestCase.CheckGETResponseContains(Expected: string; URL: string =
var
Actual: string;
begin
if Pos('http', URL) <> 1 then URL := 'http://127.0.0.1' + URL;
if Pos('http', URL) <> 1 then URL := StrHttp127001 + URL;

Actual := IdHTTP.Get(URL);

Expand All @@ -182,7 +185,7 @@ procedure THTTPTestCase.CheckPOSTResponseEquals(Expected: string; URL: string;
var
Strings: TStrings;
begin
if Pos('http', URL) <> 1 then URL := 'http://127.0.0.1' + URL;
if Pos('http', URL) <> 1 then URL := StrHttp127001 + URL;

Strings := TStringList.Create;
try
Expand Down
2 changes: 1 addition & 1 deletion test/unittests/TestSessions.pas
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ procedure TSessionTests.TestAutoCreateNoContextHandlerFirst;
// add a configured connector TODO DOC not (Server)!
Connector := TdjHTTPConnector.Create(Server.Handler);
Connector.Host := '127.0.0.1';
Connector.Port := 80;
Connector.Port := 8080;
Connector.HTTPServer.AutoStartSession := True;
Server.AddConnector(Connector);

Expand Down

0 comments on commit 07733b6

Please sign in to comment.