aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-12-29 02:16:23 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-12-29 02:16:23 +0000
commitfcd878efcd6df8a8d052cef753305c34c1297267 (patch)
tree6af774d5a6ca3d890f3eefad8372001c3a01d57e
parent3f9c84857617b0cf0d1824664e371fb6a4cac2e3 (diff)
downloadbusybox-w32-fcd878efcd6df8a8d052cef753305c34c1297267.tar.gz
busybox-w32-fcd878efcd6df8a8d052cef753305c34c1297267.tar.bz2
busybox-w32-fcd878efcd6df8a8d052cef753305c34c1297267.zip
httpd: support for "I:index.xml" syntax (Peter Korsgaard <jacmet@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
-rw-r--r--networking/httpd.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/networking/httpd.c b/networking/httpd.c
index b31b73687..87dc4b7da 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -43,6 +43,7 @@
43 * A:127.0.0.1 # Allow local loopback connections 43 * A:127.0.0.1 # Allow local loopback connections
44 * D:* # Deny from other IP connections 44 * D:* # Deny from other IP connections
45 * E404:/path/e404.html # /path/e404.html is the 404 (not found) error page 45 * E404:/path/e404.html # /path/e404.html is the 404 (not found) error page
46 * I:index.html # Show index.html when a directory is requested
46 * 47 *
47 * P:/url:[http://]hostname[:port]/new/path 48 * P:/url:[http://]hostname[:port]/new/path
48 * # When /urlXXXXXX is requested, reverse proxy 49 * # When /urlXXXXXX is requested, reverse proxy
@@ -250,6 +251,7 @@ struct globals {
250 const char *g_query; 251 const char *g_query;
251 const char *configFile; 252 const char *configFile;
252 const char *home_httpd; 253 const char *home_httpd;
254 const char *index_page;
253 255
254 const char *found_mime_type; 256 const char *found_mime_type;
255 const char *found_moved_temporarily; 257 const char *found_moved_temporarily;
@@ -295,6 +297,7 @@ struct globals {
295#define g_query (G.g_query ) 297#define g_query (G.g_query )
296#define configFile (G.configFile ) 298#define configFile (G.configFile )
297#define home_httpd (G.home_httpd ) 299#define home_httpd (G.home_httpd )
300#define index_page (G.index_page )
298#define found_mime_type (G.found_mime_type ) 301#define found_mime_type (G.found_mime_type )
299#define found_moved_temporarily (G.found_moved_temporarily) 302#define found_moved_temporarily (G.found_moved_temporarily)
300#define last_mod (G.last_mod ) 303#define last_mod (G.last_mod )
@@ -688,6 +691,11 @@ static void parse_conf(const char *path, int flag)
688 } 691 }
689#endif 692#endif
690 693
694 if (*p0 == 'I') {
695 index_page = xstrdup(c);
696 continue;
697 }
698
691#if ENABLE_FEATURE_HTTPD_BASIC_AUTH \ 699#if ENABLE_FEATURE_HTTPD_BASIC_AUTH \
692 || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \ 700 || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \
693 || ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR 701 || ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
@@ -1836,7 +1844,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
1836 *tptr = '\0'; 1844 *tptr = '\0';
1837 1845
1838 /* Copy URL from after "GET "/"POST " to stack-allocated char[] */ 1846 /* Copy URL from after "GET "/"POST " to stack-allocated char[] */
1839 urlcopy = alloca((tptr - urlp) + sizeof("/index.html")); 1847 urlcopy = alloca((tptr - urlp) + 2 + strlen(index_page));
1840 /*if (urlcopy == NULL) 1848 /*if (urlcopy == NULL)
1841 * send_headers_and_exit(HTTP_INTERNAL_SERVER_ERROR);*/ 1849 * send_headers_and_exit(HTTP_INTERNAL_SERVER_ERROR);*/
1842 strcpy(urlcopy, urlp); 1850 strcpy(urlcopy, urlp);
@@ -2087,7 +2095,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
2087#endif /* FEATURE_HTTPD_CGI */ 2095#endif /* FEATURE_HTTPD_CGI */
2088 2096
2089 if (urlp[-1] == '/') 2097 if (urlp[-1] == '/')
2090 strcpy(urlp, "index.html"); 2098 strcpy(urlp, index_page);
2091 if (stat(tptr, &sb) == 0) { 2099 if (stat(tptr, &sb) == 0) {
2092 file_size = sb.st_size; 2100 file_size = sb.st_size;
2093 last_mod = sb.st_mtime; 2101 last_mod = sb.st_mtime;
@@ -2367,6 +2375,7 @@ int httpd_main(int argc, char **argv)
2367 sighup_handler(0); 2375 sighup_handler(0);
2368 else /* do not install HUP handler in inetd mode */ 2376 else /* do not install HUP handler in inetd mode */
2369#endif 2377#endif
2378 index_page = "index.html";
2370 parse_conf(default_path_httpd_conf, FIRST_PARSE); 2379 parse_conf(default_path_httpd_conf, FIRST_PARSE);
2371 2380
2372 xfunc_error_retval = 0; 2381 xfunc_error_retval = 0;