Browse Source

* Added TRequest.LocalPathPrefix property

git-svn-id: trunk@16371 -
joost 14 years ago
parent
commit
8c836d1d1a
1 changed files with 26 additions and 1 deletions
  1. 26 1
      packages/fcl-web/src/base/httpdefs.pp

+ 26 - 1
packages/fcl-web/src/base/httpdefs.pp

@@ -268,6 +268,8 @@ type
     FURI: String;
     FURI: String;
     FFiles : TUploadedFiles;
     FFiles : TUploadedFiles;
     FReturnedPathInfo : String;
     FReturnedPathInfo : String;
+    FLocalPathPrefix : string;
+    function GetLocalPathPrefix: string;
     procedure ParseFirstHeaderLine(const line: String);override;
     procedure ParseFirstHeaderLine(const line: String);override;
     function GetFirstHeaderLine: String;
     function GetFirstHeaderLine: String;
   Protected
   Protected
@@ -287,6 +289,7 @@ type
     destructor destroy; override;
     destructor destroy; override;
     Function  GetNextPathInfo : String;
     Function  GetNextPathInfo : String;
     Property  ReturnedPathInfo : String Read FReturnedPathInfo Write FReturnedPathInfo;
     Property  ReturnedPathInfo : String Read FReturnedPathInfo Write FReturnedPathInfo;
+    Property  LocalPathPrefix : string Read GetLocalPathPrefix;
     Property  CommandLine : String Read FCommandLine;
     Property  CommandLine : String Read FCommandLine;
     Property  Command : String read FCommand;
     Property  Command : String read FCommand;
     Property  URI : String read FURI;                // Uniform Resource Identifier
     Property  URI : String read FURI;                // Uniform Resource Identifier
@@ -381,9 +384,11 @@ Function IncludeHTTPPathDelimiter(const AStr: String): String;
 
 
 implementation
 implementation
 
 
+uses
 {$ifdef CGIDEBUG}
 {$ifdef CGIDEBUG}
-uses dbugintf;
+  dbugintf,
 {$endif}
 {$endif}
+  strutils;
 
 
 Resourcestring
 Resourcestring
   SErrContentAlreadySent        = 'HTTP Response content was already sent';
   SErrContentAlreadySent        = 'HTTP Response content was already sent';
@@ -907,6 +912,7 @@ begin
   inherited create;
   inherited create;
   FHandleGetOnPost:=True;
   FHandleGetOnPost:=True;
   FFiles:=TUploadedFiles.Create(TUPloadedFile);
   FFiles:=TUploadedFiles.Create(TUPloadedFile);
+  FLocalPathPrefix:='-';
 end;
 end;
 
 
 destructor TRequest.destroy;
 destructor TRequest.destroy;
@@ -976,6 +982,25 @@ begin
   end;
   end;
 end;
 end;
 
 
+function TRequest.GetLocalPathPrefix: string;
+var
+  pi: String;
+  i: Cardinal;
+begin
+  if FLocalPathPrefix='-' then
+    begin
+    pi := PathInfo;
+    FLocalPathPrefix := '';
+    i := 0;
+    repeat
+    i := PosEx('/',PI,i+1);
+    if i > 0 then
+      FLocalPathPrefix := FLocalPathPrefix + '../';
+    until i=0;
+    end;
+  result := FLocalPathPrefix;
+end;
+
 function TRequest.GetFieldValue(AIndex: integer): String;
 function TRequest.GetFieldValue(AIndex: integer): String;
 begin
 begin
   if AIndex = 35 then // Content
   if AIndex = 35 then // Content