[fpc-pascal] SCGI in Pascal?
Michael Van Canneyt
michael at freepascal.org
Tue Jan 27 16:58:36 CET 2015
On Tue, 27 Jan 2015, silvioprog wrote:
> On Mon, Jan 26, 2015 at 6:18 PM, Michael Van Canneyt <michael at freepascal.org> wrote:
> On Mon, 26 Jan 2015, silvioprog wrote:
> On Mon, Jan 26, 2015 at 3:32 PM, silvioprog <silvioprog at gmail.com> wrote:
> On Mon, Jan 19, 2015 at 7:17 PM, Michael Van Canneyt <michael at freepascal.org> wrote:
> On Mon, 19 Jan 2015, silvioprog wrote:
>
> I haven't found any.
>
> Michael.
>
>
> Hm... =/
>
> [...]
>
> I'll make a small FPC sample with GET in SCGI and send it here ...
>
>
> Great, please do.
>
>
> 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 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.
> 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" :)
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.
More information about the fpc-pascal
mailing list