diff options
-rw-r--r-- | networking/httpd.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index 956eecaf2..07dcd71ff 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -231,6 +231,8 @@ static const struct { | |||
231 | #endif | 231 | #endif |
232 | }; | 232 | }; |
233 | 233 | ||
234 | static const char index_html[] ALIGN1 = "index.html"; | ||
235 | |||
234 | 236 | ||
235 | struct globals { | 237 | struct globals { |
236 | int verbose; /* must be int (used by getopt32) */ | 238 | int verbose; /* must be int (used by getopt32) */ |
@@ -328,7 +330,7 @@ enum { | |||
328 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ | 330 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
329 | IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \ | 331 | IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \ |
330 | bind_addr_or_port = "80"; \ | 332 | bind_addr_or_port = "80"; \ |
331 | index_page = "index.html"; \ | 333 | index_page = index_html; \ |
332 | file_size = -1; \ | 334 | file_size = -1; \ |
333 | } while (0) | 335 | } while (0) |
334 | 336 | ||
@@ -569,6 +571,8 @@ static void parse_conf(const char *path, int flag) | |||
569 | ch = (buf[0] & ~0x20); /* toupper if it's a letter */ | 571 | ch = (buf[0] & ~0x20); /* toupper if it's a letter */ |
570 | 572 | ||
571 | if (ch == 'I') { | 573 | if (ch == 'I') { |
574 | if (index_page != index_html) | ||
575 | free((char*)index_page); | ||
572 | index_page = xstrdup(after_colon); | 576 | index_page = xstrdup(after_colon); |
573 | continue; | 577 | continue; |
574 | } | 578 | } |
@@ -2101,8 +2105,12 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) | |||
2101 | } | 2105 | } |
2102 | send_cgi_and_exit(urlcopy, prequest, length, cookie, content_type); | 2106 | send_cgi_and_exit(urlcopy, prequest, length, cookie, content_type); |
2103 | } | 2107 | } |
2108 | #endif | ||
2109 | |||
2110 | if (urlp[-1] == '/') | ||
2111 | strcpy(urlp, index_page); | ||
2112 | if (stat(tptr, &sb) == 0) { | ||
2104 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR | 2113 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR |
2105 | { | ||
2106 | char *suffix = strrchr(tptr, '.'); | 2114 | char *suffix = strrchr(tptr, '.'); |
2107 | if (suffix) { | 2115 | if (suffix) { |
2108 | Htaccess *cur; | 2116 | Htaccess *cur; |
@@ -2112,16 +2120,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) | |||
2112 | } | 2120 | } |
2113 | } | 2121 | } |
2114 | } | 2122 | } |
2115 | } | ||
2116 | #endif | 2123 | #endif |
2117 | if (prequest != request_GET && prequest != request_HEAD) { | ||
2118 | send_headers_and_exit(HTTP_NOT_IMPLEMENTED); | ||
2119 | } | ||
2120 | #endif /* FEATURE_HTTPD_CGI */ | ||
2121 | |||
2122 | if (urlp[-1] == '/') | ||
2123 | strcpy(urlp, index_page); | ||
2124 | if (stat(tptr, &sb) == 0) { | ||
2125 | file_size = sb.st_size; | 2124 | file_size = sb.st_size; |
2126 | last_mod = sb.st_mtime; | 2125 | last_mod = sb.st_mtime; |
2127 | } | 2126 | } |
@@ -2135,19 +2134,18 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) | |||
2135 | send_cgi_and_exit("/cgi-bin/index.cgi", prequest, length, cookie, content_type); | 2134 | send_cgi_and_exit("/cgi-bin/index.cgi", prequest, length, cookie, content_type); |
2136 | } | 2135 | } |
2137 | } | 2136 | } |
2138 | #endif | 2137 | /* else fall through to send_file, it errors out if open fails: */ |
2139 | /* else { | ||
2140 | * fall through to send_file, it errors out if open fails | ||
2141 | * } | ||
2142 | */ | ||
2143 | 2138 | ||
2139 | if (prequest != request_GET && prequest != request_HEAD) { | ||
2140 | /* POST for files does not make sense */ | ||
2141 | send_headers_and_exit(HTTP_NOT_IMPLEMENTED); | ||
2142 | } | ||
2144 | send_file_and_exit(tptr, | 2143 | send_file_and_exit(tptr, |
2145 | #if ENABLE_FEATURE_HTTPD_CGI | ||
2146 | (prequest != request_HEAD ? SEND_HEADERS_AND_BODY : SEND_HEADERS) | 2144 | (prequest != request_HEAD ? SEND_HEADERS_AND_BODY : SEND_HEADERS) |
2145 | ); | ||
2147 | #else | 2146 | #else |
2148 | SEND_HEADERS_AND_BODY | 2147 | send_file_and_exit(tptr, SEND_HEADERS_AND_BODY); |
2149 | #endif | 2148 | #endif |
2150 | ); | ||
2151 | } | 2149 | } |
2152 | 2150 | ||
2153 | /* | 2151 | /* |