Browse Source

+ Initial implementation

git-svn-id: trunk@4979 -
michael 19 years ago
parent
commit
5fca5d2f72
3 changed files with 70 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 2 1
      fcl/tests/README
  3. 67 0
      fcl/tests/testweb.pp

+ 1 - 0
.gitattributes

@@ -1039,6 +1039,7 @@ fcl/tests/testrtf.pp svneol=native#text/plain
 fcl/tests/testser.pp svneol=native#text/plain
 fcl/tests/testsres.pp svneol=native#text/plain
 fcl/tests/testur.pp svneol=native#text/plain
+fcl/tests/testweb.pp svneol=native#text/plain
 fcl/tests/testz.pp svneol=native#text/plain
 fcl/tests/testz2.pp svneol=native#text/plain
 fcl/tests/testzip.pp svneol=native#text/plain

+ 2 - 1
fcl/tests/README

@@ -69,4 +69,5 @@ testbf.pp    Test for BlowFish encryption (MVC)
 testbfs.pp   Test for BlowFish encryption/descryption stream (MVC)
 testzip.pp   Test for TZipper class (MVC)
 poolmm1.pp   Test for pooledmm (free) (MG)
-poolmm2.pp   Test for pooledmm (nonfree) (VS)
+poolmm2.pp   Test for pooledmm (nonfree) (VS)
+testweb.pp   Test for fpcgi (MVC)

+ 67 - 0
fcl/tests/testweb.pp

@@ -0,0 +1,67 @@
+program testweb;
+
+{$mode objfpc}{$H+}
+
+uses
+  Classes, SysUtils, httpdefs, custcgi,cgiapp,fphttp,fpcgi,
+  webutil, fpweb;
+
+Type
+  TMyWeb=Class(TCustomCGIApplication)
+    procedure HandleRequest(ARequest: TRequest; AResponse: TResponse); override;
+  end;
+
+procedure TMyWeb.HandleRequest(ARequest: TRequest; AResponse: TResponse);
+
+  Procedure AddNV(Const N,V : String);
+
+  begin
+    AResponse.Contents.Add('<TR><TD>'+N+'</TD><TD>'+V+'</TD></TR>');
+  end;
+
+Var
+  I,P : Integer;
+  N,V : String;
+
+begin
+  With AResponse.Contents do
+    begin
+    BeginUpdate;
+    Try
+      Add('<HTML><TITLE>FPC CGI Test page</TITLE><BODY>');
+      DumpRequest(ARequest,AResponse.Contents);
+      Add('<H1>CGI environment:</H1>');
+      Add('<TABLE BORDER="1">');
+      Add('<TR><TD>Name</TD><TD>Value</TD></TR>');
+      For I:=1 to GetEnvironmentVariableCount do
+        begin
+        V:=GetEnvironmentString(i);
+        P:=Pos('=',V);
+        N:=Copy(V,1,P-1);
+        system.Delete(V,1,P);
+        AddNV(N,V);
+        end;
+      Add('</TABLE>');
+      Add('</BODY></HTML>');
+    Finally
+      EndUpdate;
+    end;
+    end;
+end;
+
+Procedure Run;
+
+begin
+  With TMyWeb.Create(Nil) do
+    try
+      Initialize;
+      Run;
+    Finally
+      Free;
+    end;
+end;
+
+begin
+  Run;
+end.
+