开发者

FastCGI for C++

开发者 https://www.devze.com 2022-12-11 22:03 出处:网络
I\'ve found only two Fas开发者_运维技巧tCGI libraries for C++. There\'s the \"official\" one, and fastcgi++. How is either one better than the other? Do any others exist?What you probably want is hidd

I've found only two Fas开发者_运维技巧tCGI libraries for C++. There's the "official" one, and fastcgi++. How is either one better than the other? Do any others exist?


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


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.


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.


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.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消