bug-cgicc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-cgicc] cgicc bug when use fcgi and cgicc post


From: Stephen F. Booth
Subject: Re: [bug-cgicc] cgicc bug when use fcgi and cgicc post
Date: Mon, 24 Oct 2016 11:51:05 +0000

In order to use FastCGI with Cgicc it's necessary to create a subclass of CgiInput.  There is an example in the contrib/ directory for Cgicc 3.2.16.  Your main function will look something like:

int 
main(int /*argc*/, 
     const char **/*argv*/, 
     char **/*envp*/)
{
  unsigned count = 0;

  FCGX_Request request;

  FCGX_Init();
  FCGX_InitRequest(&request, 0, 0);

  while(FCGX_Accept_r(&request) == 0) {

    try {
      FCgiIO IO(request);
      Cgicc CGI(&IO);

      // Output the HTTP headers for an HTML document, and the HTML 4.0 DTD info
      IO << HTTPHTMLHeader() << HTMLDoctype( HTMLDoctype::eStrict ) << endl
         << html().set( "lang", "en" ).set( "dir", "ltr" ) << endl;

      // Set up the page's header and title.
      IO << head() << endl
         << title() << "GNU cgicc v" << CGI.getVersion() << title() << endl
         << head() << endl;

      // Start the HTML body
      IO << body() << endl;

      // Print out a message
      IO << h1("Cgicc/FastCGI Test") << endl
         << "PID: " << getpid() << br() << endl
         << "count: " << count++ << br() << endl;

      IO  << "Form Elements:" << br() << endl;

      for(const_form_iterator i = CGI.getElements().begin(); 
 i != CGI.getElements().end(); ++i )
        IO << i->getName() << " = " << i->getValue() << br() << endl;

      // Close the document
      IO << body() << html();
    }
    catch(const exception&) {
      // handle error condition
    }

    FCGX_Finish_r(&request);
  }

  return 0;
}

Stephen

On Sat, Oct 22, 2016 at 9:38 AM 902490 <address@hidden> wrote:
hi,when i post data to cgi,the process will exit,but get data all right.
wait for your help,thanks

env yum install -y fcgi-devel
spawn-fcgi *.cpp -o 1.cgi -lfcgi -lcgicc

#include "fcgi_stdio.h"
#include "cgicc/CgiDefs.h"
#include "cgicc/Cgicc.h"
#include "cgicc/HTTPHTMLHeader.h"
#include "cgicc/HTMLClasses.h"
#include <iostream>
#include <cstdlib>
#include <string>
#include <sys/time.h>

using namespace std;
using namespace cgicc;

int main() {
    while(FCGI_Accept()>=0) {
        FCGI_printf("Content-type:text/html;charset=utf-8\n\n");
        Cgicc cgi;

        FCGI_printf("%s","aaa");
    }
    return 0;
}

_______________________________________________
bug-cgicc mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/bug-cgicc

reply via email to

[Prev in Thread] Current Thread [Next in Thread]