Browse Source

* Fixed compilation, SendTemporaryRedirect should be a method of TResponse, not THttpHeader

git-svn-id: trunk@12989 -
joost 16 years ago
parent
commit
37dcbd6612
3 changed files with 41 additions and 23 deletions
  1. 18 1
      packages/fcl-web/src/fpapache.pp
  2. 7 6
      packages/fcl-web/src/fpweb.pp
  3. 16 16
      packages/fcl-web/src/httpdefs.pp

+ 18 - 1
packages/fcl-web/src/fpapache.pp

@@ -126,6 +126,7 @@ Var
   AlternateHandler : ap_hook_handler_t = Nil;
 
 Implementation
+uses ctypes;
 
 resourcestring
   SErrNoModuleNameForRequest = 'Could not determine HTTP module name for request';
@@ -207,12 +208,15 @@ Var
   Resp : TApacheResponse;
 
 begin
+LogErrorMessage('Test 1',3);
   Req:=TApacheRequest.CreateReq(Self,P);
   Try
     Req.InitRequestVars;
     Resp:=TApacheResponse.CreateApache(Req);
     Try
+LogErrorMessage('Test 2',3);
       HandleRequest(Req,Resp);
+LogErrorMessage('Test 3',3);
       If Not Resp.ContentSent then
         Resp.SendContent;
     Finally
@@ -333,9 +337,11 @@ Var
   Var II:Integer;
   begin
     FCriticalSection.Enter;
+LogErrorMessage('Test I',3);
     try
       if (FMaxRequests>0) and (FWorkingWebModules.Count>=FMaxRequests) then
         Raise EFPApacheError.Create(SErrTooManyRequests);
+LogErrorMessage('Test II',3);
       if (FIdleWebModules.Count>0) then
       begin
         II := FIdleWebModules.Count - 1;
@@ -347,18 +353,25 @@ Var
           FIdleWebModules.Delete(II);
         end;
       end;
+LogErrorMessage('Test III',3);
       if (M=nil) then
       begin
+LogErrorMessage('Test IV',3);
+if assigned(mc) then LogErrorMessage('Test ---',3);
         M:=MC.Create(Self);
+LogErrorMessage('Test V',3);
         M.Name := '';
       end;
+LogErrorMessage('Test VI',3);
       FWorkingWebModules.Add(M);
     finally
       FCriticalSection.Leave;
     end;
+LogErrorMessage('Test VII',3);
   end;
 
 begin
+LogErrorMessage('Test a',3);
   try
     MC:=Nil;
     M := Nil;
@@ -377,8 +390,11 @@ begin
 
       MC:=MI.ModuleClass;
     end;
+LogErrorMessage('Test b',3);
     GetAWebModule;
+LogErrorMessage('Test c',3);
     M.HandleRequest(ARequest,AResponse);
+LogErrorMessage('Test d',3);
 
     FCriticalSection.Enter;
     try
@@ -394,6 +410,7 @@ begin
       ShowRequestException(AResponse,E);
       end;
   end;
+LogErrorMessage('Test e',3);
 end;
 
 { TApacheRequest }
@@ -576,7 +593,7 @@ begin
 end;
 
 Initialization
-  BeginThread(@__dummythread);//crash prevention for simultaneous requests
+//  BeginThread(@__dummythread);//crash prevention for simultaneous requests
   sleep(300);
 
   InitApache;

+ 7 - 6
packages/fcl-web/src/fpweb.pp

@@ -38,10 +38,10 @@ Type
     Procedure DoHandleRequest(ARequest : TRequest; AResponse : TResponse; Var Handled : Boolean); override;
     Procedure DoGetContent(ARequest : TRequest; Content : TStream; Var Handled : Boolean); virtual;
     Procedure GetContent(ARequest : TRequest; Content : TStream; Var Handled : Boolean);
-    Procedure Assign(Source : TPersistent); override;
   Public
     Constructor create(ACollection : TCollection); override;
     Destructor destroy; override;
+    Procedure Assign(Source : TPersistent); override;
   published
     Property Content : String Read GetStringContent Write SetContent;
     Property Contents : TStrings Read GetContents Write SetContents;
@@ -116,7 +116,7 @@ Type
     Procedure GetTemplateContent(ARequest : TRequest; AResponse : TResponse); virtual;
     function GetContent: String;virtual;
   Public
-    Constructor CreateNew(AOwner : TComponent; CreateMode : Integer); override;
+    Constructor Create(AOwner: TComponent); override;
     Destructor Destroy; override;
     Procedure HandleRequest(ARequest : TRequest; AResponse : TResponse); override;
     Property Actions : TFPWebActions Read FActions Write SetActions;
@@ -314,12 +314,13 @@ end;
 function TCustomFPWebModule.GetOnGetAction: TGetActionEvent;
 begin
   Result:=FActions.OnGetAction;
+
 end;
 
 
 procedure TCustomFPWebModule.SetActions(const AValue: TFPWebActions);
 begin
-  if (FActions<>AValue) then;
+  if (FActions<>AValue) then
     FActions.Assign(AValue);
 end;
 
@@ -397,20 +398,20 @@ begin
   end;
 end;
 
-constructor TCustomFPWebModule.CreateNew(AOwner: TComponent; CreateMode : Integer);
+constructor TCustomFPWebModule.Create(AOwner: TComponent);
 begin
-  inherited;
   FActions:=TFPWebActions.Create(TFPWebAction);
   FTemplate:=TFPWebTemplate.Create(Self);
   FTemplateVars:=TTemplateVars.Create(TTemplateVar);
+  inherited;
 end;
 
 destructor TCustomFPWebModule.Destroy;
 begin
+  inherited Destroy;
   FreeAndNil(FTemplateVars);
   FreeAndNil(FTemplate);
   FreeAndNil(FActions);
-  inherited Destroy;
 end;
 
 

+ 16 - 16
packages/fcl-web/src/httpdefs.pp

@@ -253,7 +253,6 @@ type
     Property CookieFields : TStrings Read FCookieFields Write SetCookieFields;
     Property ContentFields: TStrings read FContentFields;
     property QueryFields : TStrings read FQueryFields;
-    Procedure SendTemporaryRedirect(const TargetURL:String);
   end;
 
 
@@ -335,6 +334,7 @@ type
     Property HeadersSent : Boolean Read FHeadersSent;
     Property ContentSent : Boolean Read FContentSent;
     property Cookies: TCookies read FCookies;
+    Procedure SendTemporaryRedirect(const TargetURL:String);
   end;
   
   { TSessionVariable }
@@ -735,21 +735,6 @@ begin
     end;
 end;
 
-procedure THTTPHeader.SendTemporaryRedirect(const TargetURL: String);
-begin
-  Location := TargetURL;
-  if FHttpVersion = '1.1' then
-    begin
-    Code := 307;// HTTP/1.1 307 HTTP_TEMPORARY_REDIRECT -> 'Temporary Redirect'
-    CodeText := 'Temporary Redirect';
-    end
-  else
-    begin
-    Code := 302;// HTTP/1.0 302 HTTP_MOVED_TEMPORARILY -> 'Found'
-    CodeText := 'Moved Temporarily';
-    end;
-end;
-
 procedure THttpHeader.SetFieldByName(const AName, AValue: String);
 var
   i: Integer;
@@ -1435,6 +1420,21 @@ begin
   SendContent;
 end;
 
+procedure TResponse.SendTemporaryRedirect(const TargetURL: String);
+begin
+  Location := TargetURL;
+  if FHttpVersion = '1.1' then
+    begin
+    Code := 307;// HTTP/1.1 307 HTTP_TEMPORARY_REDIRECT -> 'Temporary Redirect'
+    CodeText := 'Temporary Redirect';
+    end
+  else
+    begin
+    Code := 302;// HTTP/1.0 302 HTTP_MOVED_TEMPORARILY -> 'Found'
+    CodeText := 'Moved Temporarily';
+    end;
+end;
+
 procedure TResponse.SetFirstHeaderLine(const line: String);
 var
   i: Integer;