4 * Produce a page containing all FastCGI inputs
7 * Copyright (c) 1996 Open Market, Inc.
9 * See the file "LICENSE" for information on usage and redistribution
10 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 static const char rcsid[] = "$Id: echo.c,v 1.5 1999/07/28 00:29:37 roberts Exp $";
17 #include "fcgi_config.h"
28 extern char **environ;
31 #include "fcgi_stdio.h"
34 static void PrintEnv(char *label, char **envp)
36 printf("%s:<br>\n<pre>\n", label);
37 for ( ; *envp != NULL; envp++) {
38 printf("%s\n", *envp);
40 printf("</pre><p>\n");
45 char **initialEnv = environ;
48 while (FCGI_Accept() >= 0) {
49 char *contentLength = getenv("CONTENT_LENGTH");
52 printf("Content-type: text/html\r\n"
54 "<title>FastCGI echo</title>"
55 "<h1>FastCGI echo</h1>\n"
56 "Request number %d, Process ID: %d<p>\n", ++count, getpid());
58 if (contentLength != NULL) {
59 len = strtol(contentLength, NULL, 10);
66 printf("No data from standard input.<p>\n");
71 printf("Standard input:<br>\n<pre>\n");
72 for (i = 0; i < len; i++) {
73 if ((ch = getchar()) < 0) {
74 printf("Error: Not enough bytes received on standard input<p>\n");
79 printf("\n</pre><p>\n");
82 PrintEnv("Request environment", environ);
83 PrintEnv("Initial environment", initialEnv);