Skip to content
This repository
tree: bb7d914ddd
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 53 lines (36 sloc) 1.167 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
#include <cstring>
#include <cstdlib>

#include "fcgiapp.h"

using namespace std;

int main( )
{
   FCGX_Stream* in;
   FCGX_Stream* out;
   FCGX_Stream* err;

   FCGX_ParamArray envp;

   while( FCGX_Accept( &in, &out, &err, &envp ) >= 0 )
   {
      FCGX_FPrintF( out, "Content-type: text/html\n" );

      const char* p_param = FCGX_GetParam( "HTTP_COOKIE", envp );

      if( !p_param )
         FCGX_FPrintF( out, "Set-Cookie: TEST=TEST_COOKIE\n" );

      FCGX_FPrintF( out, "\r\n\r\n<html>\n<head>\n <title>Sample FCGI Post</title>\n</head>\n<body>\n" );

      if( p_param )
         FCGX_FPrintF( out, "<p>Found HTTP_COOKIE: %s</p>\n", p_param );

      const char* p_query = FCGX_GetParam( "QUERY_STRING", envp );
      if( p_query && strlen( p_query ) )
         FCGX_FPrintF( out, "<p>Query String: %s</p>\n", p_query );

      FCGX_FPrintF( out, "<pre>\nPosted Data: " );
      while( true )
      {
         int i = FCGX_GetChar( in );
         if( i == -1 )
            break;

         FCGX_PutChar( i, out );
      }

      FCGX_FPrintF( out, "</pre>\n" );
      FCGX_FPrintF( out, "</body>\n</html>\n" );
   }

   FCGX_Finish( );

   return 0;
}

Something went wrong with that request. Please try again.