From 07733b6db70ccb0a76675cf4c2ab2aeeb34840ae Mon Sep 17 00:00:00 2001 From: Michael Justin Date: Sun, 26 May 2024 18:46:14 +0200 Subject: [PATCH] use port 8080 --- demo/00_bootstrap/BootstrapDemoMain.pas | 2 +- demo/01_helloworld/MainUnit.pas | 4 ++-- demo/02_sessions/MainUnit.pas | 4 ++-- demo/03_mappings/MainUnit.pas | 4 ++-- demo/05_formlogin/MainUnit.pas | 2 +- source/djServer.pas | 2 +- test/unittests/ConfigAPITests.pas | 8 ++++---- test/unittests/HTTPTestCase.pas | 23 +++++++++++++---------- test/unittests/TestSessions.pas | 2 +- 9 files changed, 27 insertions(+), 24 deletions(-) diff --git a/demo/00_bootstrap/BootstrapDemoMain.pas b/demo/00_bootstrap/BootstrapDemoMain.pas index 9107f0cf..46f9a31d 100644 --- a/demo/00_bootstrap/BootstrapDemoMain.pas +++ b/demo/00_bootstrap/BootstrapDemoMain.pas @@ -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; diff --git a/demo/01_helloworld/MainUnit.pas b/demo/01_helloworld/MainUnit.pas index f8c14cd8..436832a4 100644 --- a/demo/01_helloworld/MainUnit.pas +++ b/demo/01_helloworld/MainUnit.pas @@ -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 diff --git a/demo/02_sessions/MainUnit.pas b/demo/02_sessions/MainUnit.pas index 1b486270..0e1e1f61 100644 --- a/demo/02_sessions/MainUnit.pas +++ b/demo/02_sessions/MainUnit.pas @@ -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 diff --git a/demo/03_mappings/MainUnit.pas b/demo/03_mappings/MainUnit.pas index 59bbb878..0c84d1d6 100644 --- a/demo/03_mappings/MainUnit.pas +++ b/demo/03_mappings/MainUnit.pas @@ -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 diff --git a/demo/05_formlogin/MainUnit.pas b/demo/05_formlogin/MainUnit.pas index b58493d7..64774b8b 100644 --- a/demo/05_formlogin/MainUnit.pas +++ b/demo/05_formlogin/MainUnit.pas @@ -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'); diff --git a/source/djServer.pas b/source/djServer.pas index a0a5dcf2..68487cd1 100644 --- a/source/djServer.pas +++ b/source/djServer.pas @@ -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'; (** diff --git a/test/unittests/ConfigAPITests.pas b/test/unittests/ConfigAPITests.pas index cebecc3e..66e69676 100644 --- a/test/unittests/ConfigAPITests.pas +++ b/test/unittests/ConfigAPITests.pas @@ -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; @@ -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; @@ -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 @@ -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'); diff --git a/test/unittests/HTTPTestCase.pas b/test/unittests/HTTPTestCase.pas index b338b2ca..2ccf27ea 100644 --- a/test/unittests/HTTPTestCase.pas +++ b/test/unittests/HTTPTestCase.pas @@ -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}); @@ -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}); @@ -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]; @@ -128,7 +131,7 @@ 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); @@ -136,7 +139,7 @@ procedure THTTPTestCase.CheckContentTypeEquals(Expected: string; URL: string; 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); @@ -144,7 +147,7 @@ procedure THTTPTestCase.CheckGETResponse200(URL: string; msg: string); 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); @@ -152,7 +155,7 @@ procedure THTTPTestCase.CheckGETResponse404(URL: string; msg: string); 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); @@ -160,7 +163,7 @@ procedure THTTPTestCase.CheckGETResponse405(URL: string; msg: string); 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); @@ -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); @@ -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 diff --git a/test/unittests/TestSessions.pas b/test/unittests/TestSessions.pas index f4c1ef2c..154df418 100644 --- a/test/unittests/TestSessions.pas +++ b/test/unittests/TestSessions.pas @@ -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);