From b292e19862ac103fbab1fbe57b91b05dcde3337e Mon Sep 17 00:00:00 2001 From: mattias Date: Tue, 14 Feb 2023 22:40:24 +0100 Subject: [PATCH] fcl-web: simpleserver: fixed parsing config file --- .../examples/simpleserver/simpleserver.pas | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/packages/fcl-web/examples/simpleserver/simpleserver.pas b/packages/fcl-web/examples/simpleserver/simpleserver.pas index 52cec3167e..fb48fbc0c5 100644 --- a/packages/fcl-web/examples/simpleserver/simpleserver.pas +++ b/packages/fcl-web/examples/simpleserver/simpleserver.pas @@ -394,7 +394,7 @@ begin FPassword:=ReadString(SConfig,KeyQuit,FPassword); FEcho:=ReadBool(SConfig,KeyEcho,FEcho); FMaxAge:=ReadInteger(SConfig,KeyMaxAge,FMaxAge); - FAPISecret:=ReadString(SConfig,keyAPI,''); + FAPISecret:=ReadString(SConfig,KeyAPI,''); FCrossOriginIsolation:=ReadBool(SConfig,KeyCOI,FCrossOriginIsolation); if ValueExists(SConfig,KeyCapture) then begin @@ -426,17 +426,26 @@ end; procedure THTTPApplication.ProcessOptions; + procedure HasGetOptionValue(var aValue: string; Const C: Char; Const S : String); + begin + if HasOption(C,S) then + aValue:=GetOptionValue(C,S); + end; + Var S : String; begin for S in GetOptionValues('x','proxy') do AddProxy(S); - FAPISecret:=GetOptionValue('A','api'); - FEcho:=HasOption('e','echo'); - Quiet:=HasOption('q','quiet'); - FPassword:=GetOptionValue('Q','quit'); - Port:=StrToIntDef(GetOptionValue('p','port'),Port); + HasGetOptionValue(FAPISecret,'A','api'); + if HasOption('e','echo') then + FEcho:=true; + if HasOption('q','quiet') then + Quiet:=true; + HasGetOptionValue(FPassword,'Q','quit'); + if HasOption('p','port') then + Port:=StrToIntDef(GetOptionValue('p','port'),Port); LoadMimeTypes; if HasOption('d','directory') then BaseDir:=GetOptionValue('d','directory'); @@ -449,9 +458,12 @@ begin IndexPageName:=GetOptionValue('i','indexpage'); if HasOption('I','interface') then InterfaceAddress:=GetOptionValue('I','interface'); - FMaxAge:=StrToIntDef(GetOptionValue('a','max-age'),FMaxAge); - FBackground:=HasOption('b','background'); - FCrossOriginIsolation:=hasOption('o','coi'); + if HasOption('a','max-age') then + FMaxAge:=StrToIntDef(GetOptionValue('a','max-age'),FMaxAge); + if HasOption('b','background') then + FBackground:=true; + if hasOption('o','coi') then + FCrossOriginIsolation:=true; if HasOption('u','capture') then begin FCaptureFileName:=GetOptionValue('u','capture');