Re: [fpc-pascal] How to use FCGI in threaded mode?
On Thu, 29 Jan 2015, silvioprog 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? This is currently not supported. If you use fastcgi in classical environment, the Apache webserver will start as many instances of the fastcgi executable as it considers necessary to handle the load. Only if you use proxy fastcgi (i.e. a separately running binary listening on a fixed port, not started in Apache), then threading may be useful. To support threading requires a major rework of the fastcgi implementation, and probably also changes to fpweb (which is not thread-safe). This is on my todo list, but you are free to try and supply a patch. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] [PATCH] Add the CreateCGIParams/FreeCGIParams methods in FCL FCGI
On Thu, 29 Jan 2015, silvioprog wrote: On Thu, Jan 29, 2015 at 7:26 PM, Michael Van Canneyt wrote: On Thu, 29 Jan 2015, silvioprog wrote: Hello, Please see this patch in attached. Can I send it to bugtracker? I don't see the point. Why do you need this ? Yes, after a while I saw that my patch seems redundant. But please notice this code below: function TFCGIRequest.ProcessFCGIRecord(AFCGIRecord: PFCGI_Header): boolean; ... else begin if not assigned(FCGIParams) then FCGIParams := TStringList.Create; GetNameValuePairsFromContentRecord(PFCGI_ContentRecord(AFCGIRecord),FCGIParams); end; It seems to offer the programmer to create an own cgiparams. Is this "if" just to create this field when the request need to use it? Yes. I usually prefer late allocation on an as-needed basis. What do you think about to create the FCGIParams field in the create of the TFCGIRequest class and remove the "if" from the ProcessFCGIRecord method? I think that the ProcessFCGIRecord method is more triggered than the constructor of the TFCGIRequest class. ProcessFCGIRecord is usually called only once or maybe twice if there are really a lot of parameters. So I seriously doubt it will make a noticeable difference in speed :) Michael.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How to use FCGI in threaded mode?
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 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('-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
[fpc-pascal] How to use FCGI in threaded mode?
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('-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 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] [PATCH] Add the CreateCGIParams/FreeCGIParams methods in FCL FCGI
On Thu, Jan 29, 2015 at 7:26 PM, Michael Van Canneyt wrote: > > > On Thu, 29 Jan 2015, silvioprog wrote: > > Hello, >> >> Please see this patch in attached. Can I send it to bugtracker? >> > > I don't see the point. Why do you need this ? Yes, after a while I saw that my patch seems redundant. But please notice this code below: function TFCGIRequest.ProcessFCGIRecord(AFCGIRecord: PFCGI_Header): boolean; ... else begin if not assigned(FCGIParams) then FCGIParams := TStringList.Create; GetNameValuePairsFromContentRecord(PFCGI_ContentRecord(AFCGIRecord),FCGIParams); end; It seems to offer the programmer to create an own cgiparams. Is this "if" just to create this field when the request need to use it? What do you think about to create the FCGIParams field in the create of the TFCGIRequest class and remove the "if" from the ProcessFCGIRecord method? I think that the ProcessFCGIRecord method is more triggered than the constructor of the TFCGIRequest class. -- 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
Re: [fpc-pascal] Is Path_Info available in FastCGI working as proxy?
On Thu, Jan 29, 2015 at 6:58 PM, Michael Van Canneyt wrote: > > On Thu, 29 Jan 2015, silvioprog wrote: > >> Hello, >> >> I've the same problem in Apache and nginx: TRequest.PathInfo always >> returns an empty string. >> >> In Apache, I'm using the the mod_proxy_fcgi module already distributed in >> Apache 24. In nginx, I'm using this configuration: >> >> location /dev/duallsms { >> fastcgi_pass localhost:8080; >> ... other configurations ... >> fastcgi_param PATH_INFO $fastcgi_path_info; # from nginx docs >> } >> >> First I've tested it on Windows, but I've noticed that it fail in Linux >> too. So I ask: is PATH_INFO available in FastCGI (working as proxy)? If >> not, what I use instead it?! >> > > PATH_INFO is not always available, you need to configure that in apache > and/or nginx. > Thanks for the information. > See http://httpd.apache.org/docs/trunk/mod/mod_proxy_fcgi.html > > The FPC fcl-web components by themselves do not try to reconstruct > PATH_INFO. > You can try determining it from SCRIPT_URI or SCRIPT_NAME. Hm... what do you think about to read it from the REQUEST_URI param? If it is good, you need to do a small change in FCL (if relevant hehe). The patch in attached allows to use the implementation below: program project1; {$mode objfpc}{$H+} uses HttpDefs, custfcgi; type { TMyFCGIRequest } TMyFCGIRequest = class(TFCGIRequest) public property CGIParams; end; { TMyFCGIHandler } TMyFCGIHandler = class(TFCGIHandler) public function CreateRequest: TFCGIRequest; override; procedure HandleRequest(ARequest: TRequest; AResponse: TResponse); override; end; { TMyFCGIHandler } function TMyFCGIHandler.CreateRequest: TFCGIRequest; begin Result := TMyFCGIRequest.Create; end; procedure TMyFCGIHandler.HandleRequest(ARequest: TRequest; AResponse: TResponse); begin // open " http://localhost/dev/duallsms/pesquisa/contato?campo=nome&filtro=fulano"; and get // the "REQUEST_URI: /dev/duallsms/pesquisa/contato?campo=nome&filtro=fulano" output AResponse.Contents.Text := 'REQUEST_URI: ' + TMyFCGIRequest(ARequest).CGIParams.Values['REQUEST_URI']; end; begin with TMyFCGIHandler.Create(nil) do try Port := 8080; Run; finally Free; end; end. -- Silvio Clécio My public projects - github.com/silvioprog 0001-fcl-web-extends-the-TFCGIRequest-class-allowing-to-u.patch Description: Binary data ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] SCGI in Pascal?
On Thu, 29 Jan 2015, silvioprog wrote: On Tue, Jan 27, 2015 at 12:58 PM, Michael Van Canneyt wrote: [...] The same can be done with FastCGI if you use mod_fastcgi and ExternalFastCGIServer. We do that at work. Currently, I don't really see the added value in SCGI. yes yes, the idea to implement thats is just to adding support to a new protocol in Free Pascal, because SCGI seems easy to be implemented hehe... (several languages implement that) Currently I'm using CGI in production, but soon I'll use FastCGI as proxy, because some times I need to debug the already published application, so using nginx or Apache proxy I can point the "Proxy Pass" to my application running in my PC and debug it. Yes, we do this too. Me too. But you can use the same CGI spec to get env. variables, query_string etc. SCGI is very easy to be implemented like CGI. I've tested this draft to get all fields of a HTML form with POST: https://gist.github.com/ArtemGr/38425. I can adapt it to Pascal too. Please do, because the current implementation is not really useful. Accepting a socket connection and writing some data is simply "TCP/IP for beginners" :) Hehehe =D Not to mention that it will block if the server sends more than 4k data. The real work is accepting content and parsing the headers. :) Yes, it can be implemented to read the buffer by demand like FCGI already does. =) If you provide an initial implementation, I will be glad to add it to fcl-web. Michael.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] [PATCH] Add the CreateCGIParams/FreeCGIParams methods in FCL FCGI
On Thu, 29 Jan 2015, silvioprog wrote: Hello, Please see this patch in attached. Can I send it to bugtracker? I don't see the point. Why do you need this ? Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] SCGI in Pascal?
On Tue, Jan 27, 2015 at 12:58 PM, Michael Van Canneyt < mich...@freepascal.org> wrote: [...] > The same can be done with FastCGI if you use mod_fastcgi and > ExternalFastCGIServer. We do that at work. > Currently, I don't really see the added value in SCGI. yes yes, the idea to implement thats is just to adding support to a new protocol in Free Pascal, because SCGI seems easy to be implemented hehe... (several languages implement that) Currently I'm using CGI in production, but soon I'll use FastCGI as proxy, because some times I need to debug the already published application, so using nginx or Apache proxy I can point the "Proxy Pass" to my application running in my PC and debug it. > >The strange thing of scgi is that the spec is so vague, I am >> surprised there are any implementations... >> >> Michael. >> >> >> Me too. But you can use the same CGI spec to get env. variables, >> query_string etc. SCGI is very easy to be implemented like CGI. I've >> tested this draft to get all fields of a HTML form with POST: >> https://gist.github.com/ArtemGr/38425. I can adapt it to Pascal too. >> > > Please do, because the current implementation is not really useful. > Accepting a socket connection and writing some data is simply "TCP/IP for > beginners" :) > Hehehe =D > Not to mention that it will block if the server sends more than 4k data. > > The real work is accepting content and parsing the headers. :) Yes, it can be implemented to read the buffer by demand like FCGI already does. =) -- 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
[fpc-pascal] [PATCH] Add the CreateCGIParams/FreeCGIParams methods in FCL FCGI
Hello, Please see this patch in attached. Can I send it to bugtracker? Thank you! -- Silvio Clécio My public projects - github.com/silvioprog 0001-fcl-web-Add-the-CreateCGIParams-FreeCGIParams-method.patch Description: Binary data ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Is Path_Info available in FastCGI working as proxy?
On Thu, 29 Jan 2015, silvioprog wrote: Hello, I've the same problem in Apache and nginx: TRequest.PathInfo always returns an empty string. In Apache, I'm using the the mod_proxy_fcgi module already distributed in Apache 24. In nginx, I'm using this configuration: location /dev/duallsms { fastcgi_pass localhost:8080; ... other configurations ... fastcgi_param PATH_INFO $fastcgi_path_info; # from nginx docs } First I've tested it on Windows, but I've noticed that it fail in Linux too. So I ask: is PATH_INFO available in FastCGI (working as proxy)? If not, what I use instead it?! PATH_INFO is not always available, you need to configure that in apache and/or nginx. See http://httpd.apache.org/docs/trunk/mod/mod_proxy_fcgi.html The FPC fcl-web components by themselves do not try to reconstruct PATH_INFO. You can try determining it from SCRIPT_URI or SCRIPT_NAME. Michael.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Is Path_Info available in FastCGI working as proxy?
Oops, and my test is: program DuallSMSFastCGITest; {$mode objfpc}{$H+} uses HttpDefs, CustFCGI; type { TMyFCGIHandler } TMyFCGIHandler = class(TFCGIHandler) public procedure HandleRequest(ARequest: TRequest; AResponse: TResponse); override; end; { TMyFCGIHandler } procedure TMyFCGIHandler.HandleRequest(ARequest: TRequest; AResponse: TResponse); begin AResponse.Contents.Text := 'PathInfo: ' + ARequest.PathInfo; end; begin with TMyFCGIHandler.Create(nil) do try Port := 8080; Initialize; Run; finally Free; end; end. FPC 2.6.4 (and FPC from trunk too). On Thu, Jan 29, 2015 at 6:09 PM, silvioprog wrote: > Hello, > > I've the same problem in Apache and nginx: TRequest.PathInfo always > returns an empty string. > > In Apache, I'm using the the mod_proxy_fcgi module already distributed in > Apache 24. In nginx, I'm using this configuration: > > location /dev/duallsms { > fastcgi_pass localhost:8080; > ... other configurations ... > fastcgi_param PATH_INFO $fastcgi_path_info; # from nginx docs > } > > First I've tested it on Windows, but I've noticed that it fail in Linux > too. So I ask: is PATH_INFO available in FastCGI (working as proxy)? If > not, what I use instead it?! > > 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
[fpc-pascal] Is Path_Info available in FastCGI working as proxy?
Hello, I've the same problem in Apache and nginx: TRequest.PathInfo always returns an empty string. In Apache, I'm using the the mod_proxy_fcgi module already distributed in Apache 24. In nginx, I'm using this configuration: location /dev/duallsms { fastcgi_pass localhost:8080; ... other configurations ... fastcgi_param PATH_INFO $fastcgi_path_info; # from nginx docs } First I've tested it on Windows, but I've noticed that it fail in Linux too. So I ask: is PATH_INFO available in FastCGI (working as proxy)? If not, what I use instead it?! Thank you! -- 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
Re: [fpc-pascal] NTP
On 2015-01-29 16:08, Graeme Geldenhuys wrote: On 2015-01-29 08:10, Torsten Bonde Christiansen wrote: Does anyone have experience on how to get the current date/time of an NTP server? If you use the Indy components, they have an example included. Great - thanks. I will have a look tomorrow. Regards, Torsten. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] NTP
On 2015-01-29 08:10, Torsten Bonde Christiansen wrote: > Does anyone have experience on how to get the current date/time of an > NTP server? If you use the Indy components, they have an example included. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] NTP
Synapse has a unit for the protocol: http://www.ararat.cz/synapse/doku.php/features On Thu, Jan 29, 2015 at 6:10 AM, Torsten Bonde Christiansen wrote: > Hi, > > Does anyone have experience on how to get the current date/time of an NTP > server? > > Regards, > Torsten. > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] access violations on new ARM hardware
Am 28.01.2015 um 17:24 schrieb Sven Barth: Could be a bug in the conversion routines from WideString to AnsiString. Since we are currently preparing release 3.0.0 it might be best to test with that as well (cause string handling was changed in 2.7.1). It shouldn't be hard to compile for WinCE either, just download the source (e.g. by using SVN) and do the following: Thanks for the instruction, very helpful. Unfortunately I have to prioritise other stuff first so this must wait. But I come back when I continue testing. Regards, Björn Schreiber -- Björn Schreiber DRIGUS GmbH ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] NTP
Hi, Does anyone have experience on how to get the current date/time of an NTP server? Regards, Torsten. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal