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.2 1999/01/30 22:27:32 roberts Exp $";
18 #if defined HAVE_UNISTD_H || __linux__
30 static void PrintEnv(FCGX_Stream *out, char *label, char **envp)
32 printf("%s:<br>\n<pre>\n", label);
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");
41 extern char **environ;
46 FCGX_Stream *in, *out, *err;
49 while (FCGX_Accept(&in, &out, &err, &envp) >= 0) {
50 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,
59 if(contentLength != NULL) {
60 len = strtol(contentLength, NULL, 10);
65 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) {
71 FCGX_FPrintF(out, "Error: Not enough bytes received "
72 "on standard input<p>\n");
75 FCGX_PutChar(ch, out);
77 FCGX_FPrintF(out, "\n</pre><p>\n");
79 PrintEnv(out, "Request environment", envp);
80 PrintEnv(out, "Initial environment", environ);