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
This commit is contained in:
parent
3f9c848576
commit
fcd878efcd
@ -43,6 +43,7 @@
|
|||||||
* A:127.0.0.1 # Allow local loopback connections
|
* A:127.0.0.1 # Allow local loopback connections
|
||||||
* D:* # Deny from other IP connections
|
* D:* # Deny from other IP connections
|
||||||
* E404:/path/e404.html # /path/e404.html is the 404 (not found) error page
|
* 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
|
* P:/url:[http://]hostname[:port]/new/path
|
||||||
* # When /urlXXXXXX is requested, reverse proxy
|
* # When /urlXXXXXX is requested, reverse proxy
|
||||||
@ -250,6 +251,7 @@ struct globals {
|
|||||||
const char *g_query;
|
const char *g_query;
|
||||||
const char *configFile;
|
const char *configFile;
|
||||||
const char *home_httpd;
|
const char *home_httpd;
|
||||||
|
const char *index_page;
|
||||||
|
|
||||||
const char *found_mime_type;
|
const char *found_mime_type;
|
||||||
const char *found_moved_temporarily;
|
const char *found_moved_temporarily;
|
||||||
@ -295,6 +297,7 @@ struct globals {
|
|||||||
#define g_query (G.g_query )
|
#define g_query (G.g_query )
|
||||||
#define configFile (G.configFile )
|
#define configFile (G.configFile )
|
||||||
#define home_httpd (G.home_httpd )
|
#define home_httpd (G.home_httpd )
|
||||||
|
#define index_page (G.index_page )
|
||||||
#define found_mime_type (G.found_mime_type )
|
#define found_mime_type (G.found_mime_type )
|
||||||
#define found_moved_temporarily (G.found_moved_temporarily)
|
#define found_moved_temporarily (G.found_moved_temporarily)
|
||||||
#define last_mod (G.last_mod )
|
#define last_mod (G.last_mod )
|
||||||
@ -688,6 +691,11 @@ static void parse_conf(const char *path, int flag)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (*p0 == 'I') {
|
||||||
|
index_page = xstrdup(c);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH \
|
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH \
|
||||||
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \
|
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \
|
||||||
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
|
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
|
||||||
@ -1836,7 +1844,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
|
|||||||
*tptr = '\0';
|
*tptr = '\0';
|
||||||
|
|
||||||
/* Copy URL from after "GET "/"POST " to stack-allocated char[] */
|
/* 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)
|
/*if (urlcopy == NULL)
|
||||||
* send_headers_and_exit(HTTP_INTERNAL_SERVER_ERROR);*/
|
* send_headers_and_exit(HTTP_INTERNAL_SERVER_ERROR);*/
|
||||||
strcpy(urlcopy, urlp);
|
strcpy(urlcopy, urlp);
|
||||||
@ -2087,7 +2095,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
|
|||||||
#endif /* FEATURE_HTTPD_CGI */
|
#endif /* FEATURE_HTTPD_CGI */
|
||||||
|
|
||||||
if (urlp[-1] == '/')
|
if (urlp[-1] == '/')
|
||||||
strcpy(urlp, "index.html");
|
strcpy(urlp, index_page);
|
||||||
if (stat(tptr, &sb) == 0) {
|
if (stat(tptr, &sb) == 0) {
|
||||||
file_size = sb.st_size;
|
file_size = sb.st_size;
|
||||||
last_mod = sb.st_mtime;
|
last_mod = sb.st_mtime;
|
||||||
@ -2367,6 +2375,7 @@ int httpd_main(int argc, char **argv)
|
|||||||
sighup_handler(0);
|
sighup_handler(0);
|
||||||
else /* do not install HUP handler in inetd mode */
|
else /* do not install HUP handler in inetd mode */
|
||||||
#endif
|
#endif
|
||||||
|
index_page = "index.html";
|
||||||
parse_conf(default_path_httpd_conf, FIRST_PARSE);
|
parse_conf(default_path_httpd_conf, FIRST_PARSE);
|
||||||
|
|
||||||
xfunc_error_retval = 0;
|
xfunc_error_retval = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user