Skip to content

Instantly share code, notes, and snippets.

@joseph-montanez
Created July 27, 2011 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joseph-montanez/1108814 to your computer and use it in GitHub Desktop.
Save joseph-montanez/1108814 to your computer and use it in GitHub Desktop.
FastCGI example that doesn't work, well kind of
program ffcgi;
{$mode objfpc}{$H+}
uses
fpWeb, fpfCGI, wmecho;
begin
Application.Title:='Gorilla3D';
Application.Initialize;
Application.Port:= 9090;
Application.Run;
end.
AddHandler fastcgi-script .fcgi
ScriptAlias /pas /home/joseph/fcgi/fprun
FastCgiExternalServer /home/joseph/fcgi/fprun -host 0.0.0.0:9090 -idle-timeout 30 -flush
<Directory /home/joseph/fcgi/>
Options +ExecCGI
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
all:
/usr/local/lib/fpc/2.4.4/ppc386 -g fprun.pas;
unit wmecho;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, HTTPDefs, websession, fpHTTP,
fpWeb;
type
{ TEchoModule }
TEchoModule = class(TCustomHTTPModule)
procedure HandleRequest(ARequest : TRequest; AResponse : TResponse); override;
procedure EchoModuleRequest(Sender: TObject; ARequest: TRequest;
AResponse: TResponse; var Handled: Boolean);
private
{ private declarations }
public
{ public declarations }
end;
var
EchoModule: TEchoModule;
implementation
uses webutil;
{ TEchoModule }
procedure TEchoModule.HandleRequest(ARequest : TRequest; AResponse : TResponse);
begin
end;
procedure TEchoModule.EchoModuleRequest(Sender: TObject; ARequest: TRequest;
AResponse: TResponse; var Handled: Boolean);
Var
S : TStrings;
begin
S:=TStringList.Create;
try
// Analyze request.
DumpRequest(ARequest,S);
// Optional, because default.
AResponse.ContentType:='text/html';
AResponse.Contents:=S;
Handled:=True;
finally
S.Free;
end;
end;
initialization
RegisterHTTPModule(TEchoModule);
end.
@joseph-montanez
Copy link
Author

When I access: http://localhost/pas

I get this response:

<title>Gorilla3D: Module Error</title>

Gorilla3D: ERROR




The application encountered the following error:
  • Error: Failed to initialize component class "TEchoModule": No streaming method available.
  • Stack trace:
    $08076B33
    $080B1085
    $080B1671
    $080480EC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment