aboutsummaryrefslogtreecommitdiffstats
path: root/package/uhttpd/src/uhttpd-file.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2010-08-14 00:54:24 +0000
committerJo-Philipp Wich <jow@openwrt.org>2010-08-14 00:54:24 +0000
commitf2b534d341b5de0e8deb492e347ae7ad0b99f728 (patch)
tree8d0b10e569b8442856250d14d15eab8e7e45692c /package/uhttpd/src/uhttpd-file.c
parent63991ba875e46f40324352a5317d144465567833 (diff)
downloadupstream-f2b534d341b5de0e8deb492e347ae7ad0b99f728.tar.gz
upstream-f2b534d341b5de0e8deb492e347ae7ad0b99f728.tar.bz2
upstream-f2b534d341b5de0e8deb492e347ae7ad0b99f728.zip
uhttpd: - more robust handling of network failures on static file serving - support unlimited amount of authentication realms, listener and client sockets - support for interpreters (.php => /usr/bin/php-cgi)
SVN-Revision: 22630
Diffstat (limited to 'package/uhttpd/src/uhttpd-file.c')
-rw-r--r--package/uhttpd/src/uhttpd-file.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/package/uhttpd/src/uhttpd-file.c b/package/uhttpd/src/uhttpd-file.c
index ef9a77b6cc..25a5f6ece3 100644
--- a/package/uhttpd/src/uhttpd-file.c
+++ b/package/uhttpd/src/uhttpd-file.c
@@ -98,9 +98,9 @@ static char * uh_file_header_lookup(struct http_request *req, const char *name)
}
#define ensure_ret(x) \
- do { if( x < 0 ) return; } while(0)
+ do { if( x < 0 ) return -1; } while(0)
-static void uh_file_response_ok_hdrs(struct client *cl, struct http_request *req, struct stat *s)
+static int uh_file_response_ok_hdrs(struct client *cl, struct http_request *req, struct stat *s)
{
ensure_ret(uh_http_sendf(cl, NULL, "Connection: close\r\n"));
@@ -110,26 +110,26 @@ static void uh_file_response_ok_hdrs(struct client *cl, struct http_request *req
ensure_ret(uh_http_sendf(cl, NULL, "Last-Modified: %s\r\n", uh_file_unix2date(s->st_mtime)));
}
- ensure_ret(uh_http_sendf(cl, NULL, "Date: %s\r\n", uh_file_unix2date(time(NULL))));
+ return uh_http_sendf(cl, NULL, "Date: %s\r\n", uh_file_unix2date(time(NULL)));
}
-static void uh_file_response_200(struct client *cl, struct http_request *req, struct stat *s)
+static int uh_file_response_200(struct client *cl, struct http_request *req, struct stat *s)
{
ensure_ret(uh_http_sendf(cl, NULL, "HTTP/%.1f 200 OK\r\n", req->version));
- uh_file_response_ok_hdrs(cl, req, s);
+ return uh_file_response_ok_hdrs(cl, req, s);
}
-static void uh_file_response_304(struct client *cl, struct http_request *req, struct stat *s)
+static int uh_file_response_304(struct client *cl, struct http_request *req, struct stat *s)
{
ensure_ret(uh_http_sendf(cl, NULL, "HTTP/%.1f 304 Not Modified\r\n", req->version));
- uh_file_response_ok_hdrs(cl, req, s);
+ return uh_file_response_ok_hdrs(cl, req, s);
}
-static void uh_file_response_412(struct client *cl, struct http_request *req)
+static int uh_file_response_412(struct client *cl, struct http_request *req)
{
- ensure_ret(uh_http_sendf(cl, NULL,
+ return uh_http_sendf(cl, NULL,
"HTTP/%.1f 412 Precondition Failed\r\n"
- "Connection: close\r\n", req->version));
+ "Connection: close\r\n", req->version);
}
static int uh_file_if_match(struct client *cl, struct http_request *req, struct stat *s)
@@ -350,7 +350,7 @@ void uh_file_request(struct client *cl, struct http_request *req, struct path_in
uh_file_if_none_match(cl, req, &pi->stat)
) {
/* write status */
- uh_file_response_200(cl, req, &pi->stat);
+ ensure_out(uh_file_response_200(cl, req, &pi->stat));
ensure_out(uh_http_sendf(cl, NULL, "Content-Type: %s\r\n", uh_file_mime_lookup(pi->name)));
ensure_out(uh_http_sendf(cl, NULL, "Content-Length: %i\r\n", pi->stat.st_size));
@@ -385,7 +385,7 @@ void uh_file_request(struct client *cl, struct http_request *req, struct path_in
else if( (pi->stat.st_mode & S_IFDIR) && !cl->server->conf->no_dirlists )
{
/* write status */
- uh_file_response_200(cl, req, NULL);
+ ensure_out(uh_file_response_200(cl, req, NULL));
if( req->version > 1.0 )
ensure_out(uh_http_send(cl, NULL, "Transfer-Encoding: chunked\r\n", -1));