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.2 1999/01/30 22:27:31 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;
44 while(FCGI_Accept() >= 0) {
45 char *contentLength = getenv("CONTENT_LENGTH");
47 printf("Content-type: text/html\r\n"
49 "<title>FastCGI echo</title>"
50 "<h1>FastCGI echo</h1>\n"
51 "Request number %d, Process ID: %d<p>\n", ++count, getpid());
52 if(contentLength != NULL) {
53 len = strtol(contentLength, NULL, 10);
58 printf("No data from standard input.<p>\n");
61 printf("Standard input:<br>\n<pre>\n");
62 for(i = 0; i < len; i++) {
63 if((ch = getchar()) < 0) {
64 printf("Error: Not enough bytes received "
65 "on standard input<p>\n");
70 printf("\n</pre><p>\n");
72 PrintEnv("Request environment", environ);
73 PrintEnv("Initial environment", initialEnv);