FastCGI-Qt

Introduction

FastCGI-Qt is a library to make writing FastCGI applications using Qt easy.

Unlike the majority of existing libraries, FastCGI-Qt aims to provide a clean interface to the data provided by the client or web server, instead of merely providing a CGI/1.1-compatible environment.

This interface is provided by three main classes:

Writing an application with FastCGI-Qt

Only three things are needed to make a FastCGI application with FastCGI-Qt:

A simple "Hello, World" application is used as an example.

Header File

#include <FastCgiQt/Responder.h>

class HelloWorld : public FastCgiQt::Responder
{
        Q_OBJECT;
        RESPONDER(HelloWorld);
        public:
                void respond();
};

This declares a subclass of FastCgiQt::Responder called "HelloWorld", which overrides FastCgiQt::Responder::respond().

The RESPONDER macro does two things:

This means that all that has to be written by hand is the respond() function.

Implementation File

#include "HelloWorld.h"

void HelloWorld::respond()
{
        out << "<h1>" << tr("hello, world") << "</h1>";
}

This just writes a content-type header, and the traditional greeting (though with translation support).

main.cpp

#include "HelloWorld.h"
#include <FastCgiQt/Manager.h>

#include <QCoreApplication>

int main(int argc, char** argv)
{
        QCoreApplication application(argc, argv);
        application.setApplicationName("HelloWorld");

        FastCgiQt::Manager manager(&HelloWorld::create);

        return application.exec();
}

This:

  1. Sets up the QCoreApplication.
            QCoreApplication application(argc, argv);
            application.setApplicationName("HelloWorld");
    
  2. Creates a manager, passing it a pointer to the static generator function defined by RESPONDER.
            FastCgiQt::Manager manager(&HelloWorld::create);
    
  3. Starts the application running.
            return application.exec();
    

Other Examples

There are several examples included in the FastCGI-Qt source:

Source

The source code for FastCGI-Qt can be browsed via gitweb.

You can obtain the code via git:

git clone http://git.fredemmott.co.uk/repo/FastCgiQt 

License

With the exception of the file 'fastcgi.h', FastCGI-Qt is licensed under the ISC license:

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

The file 'fastcgi.h' is not under the same license, as it is taken from the FastCGI development kit. This file is not part of the user API for FastCGI-Qt.

It is under the following license:

This FastCGI application library source and object code (the
"Software") and its documentation (the "Documentation") are
copyrighted by Open Market, Inc ("Open Market").  The following terms
apply to all files associated with the Software and Documentation
unless explicitly disclaimed in individual files.

Open Market permits you to use, copy, modify, distribute, and license
this Software and the Documentation for any purpose, provided that
existing copyright notices are retained in all copies and that this
notice is included verbatim in any distributions.  No written
agreement, license, or royalty fee is required for any of the
authorized uses.  Modifications to this Software and Documentation may
be copyrighted by their authors and need not follow the licensing
terms described here.  If modifications to this Software and
Documentation have new licensing terms, the new terms must be clearly
indicated on the first page of each file where they apply.

OPEN MARKET MAKES NO EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE
SOFTWARE OR THE DOCUMENTATION, INCLUDING WITHOUT LIMITATION ANY
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  IN
NO EVENT SHALL OPEN MARKET BE LIABLE TO YOU OR ANY THIRD PARTY FOR ANY
DAMAGES ARISING FROM OR RELATING TO THIS SOFTWARE OR THE
DOCUMENTATION, INCLUDING, WITHOUT LIMITATION, ANY INDIRECT, SPECIAL OR
CONSEQUENTIAL DAMAGES OR SIMILAR DAMAGES, INCLUDING LOST PROFITS OR
LOST DATA, EVEN IF OPEN MARKET HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.  THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS".
OPEN MARKET HAS NO LIABILITY IN CONTRACT, TORT, NEGLIGENCE OR
OTHERWISE ARISING OUT OF THIS SOFTWARE OR THE DOCUMENTATION.

Generated on Sat Aug 22 19:44:56 2009 for FastCGI-Qt by  doxygen 1.5.7