4 * Produce a page containing all the inputs (fcgiapp version)
7 * Copyright (c) 1996 Open Market, Inc.
9 * See the file "LICENSE.TERMS" for information on usage and redistribution
10 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 static const char rcsid[] = "$Id: echo-x.c,v 1.1 2001/06/19 15:06:17 robs Exp $";
17 #include "fcgi_config.h"
28 extern char **environ;
33 static void PrintEnv(FCGX_Stream *out, char *label, char **envp)
35 FCGX_FPrintF(out, "%s:<br>\n<pre>\n", label);
36 for( ; *envp != NULL; envp++) {
37 FCGX_FPrintF(out, "%s\n", *envp);
39 FCGX_FPrintF(out, "</pre><p>\n");
44 FCGX_Stream *in, *out, *err;
48 while (FCGX_Accept(&in, &out, &err, &envp) >= 0) {
49 char *contentLength = FCGX_GetParam("CONTENT_LENGTH", envp);
53 "Content-type: text/html\r\n"
55 "<title>FastCGI echo (fcgiapp version)</title>"
56 "<h1>FastCGI echo (fcgiapp version)</h1>\n"
57 "Request number %d, Process ID: %d<p>\n", ++count, getpid());
59 if (contentLength != NULL)
60 len = strtol(contentLength, NULL, 10);
63 FCGX_FPrintF(out, "No data from standard input.<p>\n");
68 FCGX_FPrintF(out, "Standard input:<br>\n<pre>\n");
69 for (i = 0; i < len; i++) {
70 if ((ch = FCGX_GetChar(in)) < 0) {
72 "Error: Not enough bytes received on standard input<p>\n");
75 FCGX_PutChar(ch, out);
77 FCGX_FPrintF(out, "\n</pre><p>\n");
80 PrintEnv(out, "Request environment", envp);
81 PrintEnv(out, "Initial environment", environ);