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.
15 static const char rcsid[] = "$Id: echo2.c,v 1.4 1999/07/26 05:33:00 roberts Exp $";
18 #if defined HAVE_UNISTD_H || __linux__
28 extern char **environ;
31 static void PrintEnv(FCGX_Stream *out, char *label, char **envp)
33 FCGX_FPrintF(out, "%s:<br>\n<pre>\n", label);
34 for( ; *envp != NULL; envp++) {
35 FCGX_FPrintF(out, "%s\n", *envp);
37 FCGX_FPrintF(out, "</pre><p>\n");
42 FCGX_Stream *in, *out, *err;
46 while (FCGX_Accept(&in, &out, &err, &envp) >= 0) {
47 char *contentLength = FCGX_GetParam("CONTENT_LENGTH", envp);
51 "Content-type: text/html\r\n"
53 "<title>FastCGI echo (fcgiapp version)</title>"
54 "<h1>FastCGI echo (fcgiapp version)</h1>\n"
55 "Request number %d, Process ID: %d<p>\n", ++count, getpid());
57 if (contentLength != NULL)
58 len = strtol(contentLength, NULL, 10);
61 FCGX_FPrintF(out, "No data from standard input.<p>\n");
66 FCGX_FPrintF(out, "Standard input:<br>\n<pre>\n");
67 for (i = 0; i < len; i++) {
68 if ((ch = FCGX_GetChar(in)) < 0) {
70 "Error: Not enough bytes received on standard input<p>\n");
73 FCGX_PutChar(ch, out);
75 FCGX_FPrintF(out, "\n</pre><p>\n");
78 PrintEnv(out, "Request environment", envp);
79 PrintEnv(out, "Initial environment", environ);