Procházet zdrojové kódy

* Partially applied the patch from Attila Borka, added UseStreaming class method so datamodules without streamed content can be used (bug ID 12158)

git-svn-id: trunk@11800 -
michael před 17 roky
rodič
revize
0d1ec12788

+ 5 - 2
packages/fcl-web/src/fpapache.pp

@@ -376,11 +376,14 @@ begin
         Raise EFPApacheError.CreateFmt(SErrNoModuleForRequest,[MN]);
         end;
       MC:=MI.ModuleClass;
-      M:=FindModule(MC); // Check if a module exists already
       end;
+    M:=FindModule(MC); // Check if a module exists already
     If (M=Nil) then
       begin
-      M:=MC.Create(Self);
+      If MC.UseStreaming then
+        M:=MC.Create(Self)
+      else  
+        M:=MC.CreateNew(Self,0);
       end;
     M.HandleRequest(ARequest,AResponse);
   except

+ 16 - 5
packages/fcl-web/src/fpcgi.pp

@@ -75,14 +75,20 @@ end;
 
 function TCGIApplication.GetModuleName(Arequest: TRequest): string;
 
+Var
+  S : String;
+
 begin
   If (FModuleVar<>'') then
     Result:=ARequest.QueryFields.Values[FModuleVar];//Module name from query parameter using the FModuleVar as parameter name (default is 'Module')
   If (Result='') then
-  begin
-    if (Pos('/', ARequest.PathInfo[2]) <= 0) and AllowDefaultModule then Exit;//There is only 1 '/' in ARequest.PathInfo -> only ActionName is there -> use default module
+    begin
+    S:=ARequest.PathInfo;
+    Delete(S,1,1);
+    if (Pos('/',S) <= 0) and AllowDefaultModule then 
+      Exit;//There is only 1 '/' in ARequest.PathInfo -> only ActionName is there -> use default module
     Result:=ARequest.GetNextPathInfo;
-  end;
+    end;
 end;
 
 function TCGIApplication.FindModule(ModuleClass : TCustomHTTPModuleClass): TCustomHTTPModule;
@@ -139,10 +145,15 @@ begin
       Raise EFPCGIError.CreateFmt(SErrNoModuleForRequest,[MN]);
       end;
     MC:=MI.ModuleClass;
-    M:=FindModule(MC); // Check if a module exists already
     end;
+  M:=FindModule(MC); // Check if a module exists already
   If (M=Nil) then
-    M:=MC.Create(Self);
+    begin
+    If MC.UseStreaming then
+      M:=MC.Create(Self)
+    else  
+      M:=MC.CreateNew(Self,0);
+    end;  
   M.HandleRequest(ARequest,AResponse);
 end;
 

+ 9 - 0
packages/fcl-web/src/fphttp.pp

@@ -94,6 +94,7 @@ Type
   
   TCustomHTTPModule = Class(TDataModule)
   public
+    Class Function UseStreaming : Boolean; virtual;
     Procedure HandleRequest(ARequest : TRequest; AResponse : TResponse); virtual; abstract;
   end;
   
@@ -407,6 +408,14 @@ begin
     Dec(Result);
 end;
 
+{ TCustomHTTPModule }
+
+Class Function TCustomHTTPModule.UseStreaming : Boolean; 
+
+begin
+  Result:=True;
+end;
+    
 Initialization
   ModuleFactory:=TModuleFactory.Create(TModuleItem);
 

+ 2 - 1
packages/fcl-web/src/httpdefs.pp

@@ -1047,8 +1047,9 @@ begin
 end;
 
 function TRequest.GetTempUploadFileName: String;
+
 begin
-  Result:=GetTempFileName('/tmp/','CGI')
+  Result := GetTempFileName(GetTempDir, 'CGI');
 end;