#if HAVE_AFINET6 -> #ifdef HAVE_AFINET6
[oweals/busybox.git] / networking / httpd.c
index 08b40e014fdebd83cbfce2329b19204e1aac1783..b82e9f9951cf9010e52e925c8bca676d30612d96 100644 (file)
@@ -24,6 +24,9 @@
  * server changes directory to the location of the script and executes it
  * after setting QUERY_STRING and other environment variables.
  *
+ * Doc:
+ * "CGI Environment Variables": http://hoohoo.ncsa.uiuc.edu/cgi/env.html
+ *
  * The server can also be invoked as a url arg decoder and html text encoder
  * as follows:
  *  foo=`httpd -d $foo`           # decode "Hello%20World" as "Hello World"
@@ -1036,6 +1039,13 @@ static int sendCgi(const char *url,
                setenv1("SCRIPT_FILENAME", realpath_buff);
                /* set SCRIPT_NAME as full path: /cgi-bin/dirs/script.cgi */
                setenv1("SCRIPT_NAME", purl);
+               /* http://hoohoo.ncsa.uiuc.edu/cgi/env.html:
+                * QUERY_STRING: The information which follows the ? in the URL
+                * which referenced this script. This is the query information.
+                * It should not be decoded in any fashion. This variable
+                * should always be set when there is query information,
+                * regardless of command line decoding. */
+               /* (Older versions of bbox seemed to do some decoding) */
                setenv1("QUERY_STRING", config->query);
                setenv1("SERVER_SOFTWARE", httpdVersion);
                putenv("SERVER_PROTOCOL=HTTP/1.0");
@@ -1756,22 +1766,19 @@ static int miniHttpd(int server)
                /* set the KEEPALIVE option to cull dead connections */
                on = 1;
                setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, (void *)&on, sizeof(on));
-#if !DEBUG
-               if (fork() == 0)
-#endif
-               {
-                       /* This is the spawned thread */
+
+               if (DEBUG || fork() == 0) {
+                       /* child */
 #if ENABLE_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP
                        /* protect reload config, may be confuse checking */
                        signal(SIGHUP, SIG_IGN);
 #endif
                        handleIncoming();
-#if !DEBUG
-                       exit(0);
-#endif
+                       if (!DEBUG)
+                               exit(0);
                }
                close(s);
-       } // while (1)
+       } /* while (1) */
        return 0;
 }