Oops, I forgot an additional information: i'm using Lazarus 1.2.6 / FPC 2.6.4 and FCGI as proxy (usgin native modules) in Apache 2.4 on Windos 7 64 bits.
On Thu, Jan 29, 2015 at 8:08 PM, silvioprog <silviop...@gmail.com> wrote: > Hello, > > Using the TCustomHTTPApplication class, I just set the "Threaded" property > to true, and my application works in threaded mode. But, how to do the same > in TCustomFCgiApplication class? > > To test it, compile and run the code below. After, open two tabs in your > browser. In tab 1, open the "http://localhost/test?op=loop" URL, in tab > 2, open the "http://localhost/test" URL. Notice that the tab 2 will wait > 10 seconds to show the result. > > program project1; > > {$mode objfpc}{$H+} > > uses > {$IFDEF UNIX} > CThreads, > {$ENDIF} > CustWeb, HttpDefs, CustFCGI, Classes, SysUtils; > > type > > { TMyFCGIApplication } > > TMyFCGIApplication = class(TCustomFCgiApplication) > protected > function InitializeWebHandler: TWebHandler; override; > end; > > { TMyFCGIHandler } > > TMyFCGIHandler = class(TFCGIHandler) > public > procedure HandleRequest(ARequest: TRequest; AResponse: TResponse); > override; > end; > > { TMyFCGIApplication } > > function TMyFCGIApplication.InitializeWebHandler: TWebHandler; > begin > Result := TMyFCGIHandler.Create(Self); > end; > > { TMyFCGIHandler } > > procedure TMyFCGIHandler.HandleRequest(ARequest: TRequest; AResponse: > TResponse); > var > I: Integer; > begin > if ARequest.QueryFields.Values['op'] = 'loop' then > begin > for I := 1 to 10 do > Sleep(1000); > AResponse.Contents.Text := 'Done!'; > end > else > AResponse.Contents.Text := > 'Now: ' + FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', Now); > end; > > begin > with TMyFCGIApplication.Create(nil) do > try > Port := 8080; > Run; > finally > Free; > end; > end. > > Thank you! > > -- > Silvio Clécio > My public projects - github.com/silvioprog > -- Silvio Clécio My public projects - github.com/silvioprog
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal