Hello,
Can any one inform if exists a FPC or Delphi implementation to this protocol [1]?
Thank you!
[1] - http://en.wikipedia.org/wiki/Simple_Common_Gateway_Interface

Mailing lists / fpc-pascal / 2015-01
14 messages · 4 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Hello,
Can any one inform if exists a FPC or Delphi implementation to this protocol [1]?
Thank you!
[1] - http://en.wikipedia.org/wiki/Simple_Common_Gateway_Interface
I haven't found any.
Michael.
Can any one inform if exists a FPC or Delphi implementation to this protocol [1]? Thank…
silvioprog wroteCan any one inform if exists a FPC or Delphi implementation to this protocol [1]?
You'd better ask in the Lazarus list. Lazarus does provide some basic CGI and FCGI support. Maybe SCGI can build on this.
-Michael
"Michael Schnell" wroteOn 01/19/2015 06:31 PM, silvioprog wrote: > > Can any one inform if exists a FPC or Delphi implementation to this
protocol [1]?
You'd better ask in the Lazarus list. Lazarus does provide some basic CGI
and FCGI support. Maybe SCGI can build on this.
You do know that the base for what Lazarus provides comes from FPC? (fpweb and friends)
Regards,
Sven
You'd better ask in the Lazarus list. Lazarus does provide some basic CGI and FCGI…
The CGI and FastCGI support resides in FPC. I wrote most of the web functionality.
Michael.
I haven't found any. Michael.
On Mon, Jan 19, 2015 at 7:17 PM, Michael Van Canneyt <
Hm... =/
I found a project written in Java. Tested with Apache on Windows and worked fine (and very fast like FastCGI).
The project is:
https://github.com/intrbiz/balsa-scgi
I saw the sources of this project and it seems very simple to implement it in FPC using the HTTPDefs/sscokets unit.
The SCGI protocol is simple like CGI and fast like FastCGI, and very easy to configure in several popular HTTP servers (tested in Apache) like Apache, nginx, Lighttpd, M$ IIS etc. My steps in Apache on Windows 7:
1. download and install the "httpd-2.2.22-win32-x86-openssl-0.9.8t.msi" file from https://archive.apache.org/dist/httpd/binaries/win32/ ;
2. download the "scgi-1.13-apache-2.2.13.zip" file from https://sites.google.com/site/bigonez/ ;
3. copy the "mod_scgi.so" from "scgi-1.13-apache-2.2.13.zip" to the "C:\YOUR_APACHE_FOLDER\modules" folder;
4. in your "C:\YOUR_APACHE_FOLDER\conf\httpd.conf" file, add the lines: LoadModule scgi_module modules/mod_scgi.so
SCGIMount /teste 127.0.0.1:8080 ;5. restart your Apache.
Download Balsa SCGI from https://github.com/intrbiz/balsa-scgi and open it in your favorite IDE, like Intellij IDEA, Eclipse, NetBeans etc., I use Intellij IDEA. In SCGIExample.java, change the "port = 8090" to "port = 8080", run the app and in your browser, open: http://localhost/test.
See a screen shot of my test in attached.
SCGI can be a nice alternative to FastCGI (and FPC could be added in "Language bindings for the SCGI API" -
http://en.wikipedia.org/wiki/Simple_Common_Gateway_Interface).
[...]
I'll make a small FPC sample with GET in SCGI and send it here ...
Great, please do.
The strange thing of scgi is that the spec is so vague, I am surprised there are any implementations...
Michael.
On Mon, Jan 26, 2015 at 6:18 PM, Michael Van Canneyt <
Done! =)
Tested with FCL and Synapse (demo in attached or in Dropbox: https://www.dropbox.com/s/rei2fj5papyqium/SCGI_GET.zip?dl=0). My demo is just a "hello world", showing how to do a GET in a SCGI application. I'm using only sockets, but it can be easily implemented with HTTPDefs.pas pre-implementation, to make something like custscgi.pas.
Below you can see how to test my small app in seven steps, on Windows 7 and using nginx as HTTP server. It is very easy to do, please see:
1. download the nginx server http://nginx.org/en/download.html (I'm using the nginx-1.7.9);
2. unpack nginx-1.7.9.zip, and in nginx-1.7.9 folder, open the nginx-1.7.9\conf\nginx.conf file;
3. in nginx.conf file, add the following content (see my nginx.conf here: http://pastebin.com/7xB6nmJz, line 79):
location /test {
include scgi_params;
scgi_pass localhost:8080;
}4. open the CMD, go into the nginx-1.7.9 folder using CD, and execute nginx.exe;
5. compile and run the SCGI_GET\FCL\project1.lpr project;
6. open the http://localhost/test URL in you browser;
7. enjoy! =)
Please tell me if those steps also worked for you.
You can test it in Apache too (Windows or Linux), I tested it using the steps that I told before and it worked like a charm too.
Now I need to test the SCGI performance comparing it with FastCGI (+- 6.000 request / sec) and Apache module (+- 14.000 requests / sec).
I'm very impressed with the ease in debugging a SCGI application.
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.
The same can be done with FastCGI if you use mod_fastcgi and ExternalFastCGIServer. We do , I don't really see the added value in SCGI.
Please do, because the current implementation is not really useful. Accepting a socket connection and writing some data is simply "TCP/IP for beginners" :) 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. :)
Michael.
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.
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. =)
Yes, we do this too.
If you provide an initial implementation, I will be glad to add it to fcl-web.
Michael.
On Thu, Jan 29, 2015 at 7:27 PM, Michael Van Canneyt <
Awesome. I started it. =)
Maybe it take a while because my chronic lack of time, but I've created an environment to implement it.
We all suffer from chronic lack of time, but if each does a small piece, we'll get there :)
Michael.