svn commit: trunk/busybox/networking

vda at busybox.net vda at busybox.net
Sat Dec 29 02:16:26 UTC 2007


Author: vda
Date: 2007-12-28 18:16:23 -0800 (Fri, 28 Dec 2007)
New Revision: 20694

Log:
httpd: support for "I:index.xml" syntax (Peter Korsgaard <jacmet at uclibc.org>)

function                                             old     new   delta
parse_conf                                          1481    1507     +26
handle_incoming_and_exit                            2650    2663     +13
httpd_main                                           749     759     +10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 49/0)               Total: 49 bytes



Modified:
   trunk/busybox/networking/httpd.c


Changeset:
Modified: trunk/busybox/networking/httpd.c
===================================================================
--- trunk/busybox/networking/httpd.c	2007-12-28 17:04:42 UTC (rev 20693)
+++ trunk/busybox/networking/httpd.c	2007-12-29 02:16:23 UTC (rev 20694)
@@ -43,6 +43,7 @@
  * A:127.0.0.1       # Allow local loopback connections
  * D:*               # Deny from other IP connections
  * E404:/path/e404.html # /path/e404.html is the 404 (not found) error page
+ * I:index.html      # Show index.html when a directory is requested
  *
  * P:/url:[http://]hostname[:port]/new/path
  *                   # When /urlXXXXXX is requested, reverse proxy
@@ -250,6 +251,7 @@
 	const char *g_query;
 	const char *configFile;
 	const char *home_httpd;
+	const char *index_page;
 
 	const char *found_mime_type;
 	const char *found_moved_temporarily;
@@ -295,6 +297,7 @@
 #define g_query           (G.g_query          )
 #define configFile        (G.configFile       )
 #define home_httpd        (G.home_httpd       )
+#define index_page        (G.index_page       )
 #define found_mime_type   (G.found_mime_type  )
 #define found_moved_temporarily (G.found_moved_temporarily)
 #define last_mod          (G.last_mod         )
@@ -688,6 +691,11 @@
 		}
 #endif
 
+		if (*p0 == 'I') {
+			index_page = xstrdup(c);
+			continue;
+		}
+
 #if ENABLE_FEATURE_HTTPD_BASIC_AUTH \
  || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \
  || ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
@@ -1836,7 +1844,7 @@
 	*tptr = '\0';
 
 	/* Copy URL from after "GET "/"POST " to stack-allocated char[] */
-	urlcopy = alloca((tptr - urlp) + sizeof("/index.html"));
+	urlcopy = alloca((tptr - urlp) + 2 + strlen(index_page));
 	/*if (urlcopy == NULL)
 	 *	send_headers_and_exit(HTTP_INTERNAL_SERVER_ERROR);*/
 	strcpy(urlcopy, urlp);
@@ -2087,7 +2095,7 @@
 #endif  /* FEATURE_HTTPD_CGI */
 
 	if (urlp[-1] == '/')
-		strcpy(urlp, "index.html");
+		strcpy(urlp, index_page);
 	if (stat(tptr, &sb) == 0) {
 		file_size = sb.st_size;
 		last_mod = sb.st_mtime;
@@ -2367,6 +2375,7 @@
 		sighup_handler(0);
 	else /* do not install HUP handler in inetd mode */
 #endif
+		index_page = "index.html";
 		parse_conf(default_path_httpd_conf, FIRST_PARSE);
 
 	xfunc_error_retval = 0;




More information about the busybox-cvs mailing list