X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuhttpd.git;a=blobdiff_plain;f=file.c;h=fa37155e7159ffcded7f8aca8c78c3fa692d30c2;hp=f1f5d6d9eb210f349b8f164b4c5e27e6e1b8da1f;hb=d1659a558594908a73d9e85e3dcab402f2768b10;hpb=30fff08a44094df9b775f2e4bf9f5abceb847415 diff --git a/file.c b/file.c index f1f5d6d..fa37155 100644 --- a/file.c +++ b/file.c @@ -17,8 +17,13 @@ * limitations under the License. */ +#define _BSD_SOURCE +#define _XOPEN_SOURCE 700 + #include #include +#include +#include #include @@ -613,18 +618,25 @@ static void uh_file_request(struct client *cl, struct path_info *pi) cl->data.file.hdr = NULL; } -void uh_handle_file_request(struct client *cl) +static bool __handle_file_request(struct client *cl, const char *url) { struct path_info *pi; - pi = uh_path_lookup(cl, cl->request.url); - if (!pi) { - uh_request_done(cl); - return; - } + pi = uh_path_lookup(cl, url); + if (!pi) + return false; - if (pi->redirected) + if (!pi->redirected) + uh_file_request(cl, pi); + + return true; +} + +void uh_handle_file_request(struct client *cl) +{ + if (__handle_file_request(cl, cl->request.url) || + __handle_file_request(cl, conf.error_handler)) return; - uh_file_request(cl, pi); + uh_client_error(cl, 404, "Not Found", "No such file or directory"); }