-->

FastCGI for C++

2019-03-10 02:37发布

问题:

I've found only two FastCGI libraries for C++. There's the "official" one, and fastcgi++. How is either one better than the other? Do any others exist?

回答1:

As fastcgi++ is still listed as "Development Status: 4- Beta" so I would suggest going for the official one. It has been around for ages and has bindings for a whole host of languages. Licences between the 2 don't seem to make much difference. Put some measurements in your code and if performance is an issue then spend some time playing around with alternatives.



回答2:

What you probably want is hidden in the contrib directory of Cgicc package.

fcgi-test.cpp is an example of how to use cgicc with FastCGI.

Path to the installed fcgi-test.cpp should be /usr/share/doc/libcgicc-doc/examples/contrib/fcgi-test.cpp



回答3:

The official library is rather low-level, and as such, is only useful as an intermediate for a high-level CGI library such as cgicc.

Fastcgi++, on the other hand, allows for use of C++ idioms when dealing with FastCGI. Incompleteness in v1 motivated me to fork it into mosh-fcgi.

Pros: My fork complies with every point of the standard (especially ROLE_FILTER) everything's extensively templated, so it's easier to use arbitrary T for std::basic_strings. Cons: My modifications are in alpha mode.

In any case, download the latest zip from https://github.com/moshbear/mosh-fcgi.



回答4:

See also the Cgicc library:

http://www.gnu.org/software/cgicc/

The library appears to be mature (currently at version 3.x). According to the documentation it can be used with FastCGI by passing a custom reader (reader_function_t) to the constructor of the Cgicc class.



回答5:

There is a pretty library for creating FastCGI daemons: https://github.com/golubtsov/Fastcgi-Daemon



回答6:

The C-version of FastCGI does very little, and developing in C++ isn't such a big problem as it hardly interferes with your own code. It's most likely just a loop and an environment variable.

So my advice would be just to stick with the official version.

Just be aware of one thing: it works by redefining printf! So if you use cout it won't work.



标签: c++ fastcgi