4 * Produce a page containing all FastCGI inputs
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: echo.c,v 1.3 1999/07/26 05:32:59 roberts Exp $";
18 #if defined HAVE_UNISTD_H || __linux__
22 #include "fcgi_stdio.h"
28 extern char **environ;
31 static void PrintEnv(char *label, char **envp)
33 printf("%s:<br>\n<pre>\n", label);
34 for ( ; *envp != NULL; envp++) {
35 printf("%s\n", *envp);
37 printf("</pre><p>\n");
42 char **initialEnv = environ;
45 while (FCGI_Accept() >= 0) {
46 char *contentLength = getenv("CONTENT_LENGTH");
49 printf("Content-type: text/html\r\n"
51 "<title>FastCGI echo</title>"
52 "<h1>FastCGI echo</h1>\n"
53 "Request number %d, Process ID: %d<p>\n", ++count, getpid());
55 if (contentLength != NULL) {
56 len = strtol(contentLength, NULL, 10);
63 printf("No data from standard input.<p>\n");
68 printf("Standard input:<br>\n<pre>\n");
69 for (i = 0; i < len; i++) {
70 if ((ch = getchar()) < 0) {
71 printf("Error: Not enough bytes received on standard input<p>\n");
76 printf("\n</pre><p>\n");
79 PrintEnv("Request environment", environ);
80 PrintEnv("Initial environment", initialEnv);