-#define _XOPEN_SOURCE 500 /* strptime() ... */
-#define _BSD_SOURCE /* scandir() ... */
+/*
+ * uhttpd - Tiny non-forking httpd - Static file handler
+ *
+ * Copyright (C) 2010 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define _XOPEN_SOURCE 500 /* strptime() */
+#define _BSD_SOURCE /* scandir(), timegm() */
#include "uhttpd.h"
#include "uhttpd-utils.h"
return strcmp(e->d_name, ".") ? 1 : 0;
}
-static void uh_file_dirlist(struct client *cl, struct http_request *req, struct uh_path_info *pi)
+static void uh_file_dirlist(struct client *cl, struct http_request *req, struct path_info *pi)
{
int i, count;
char filename[PATH_MAX];
}
-void uh_file_request(struct client *cl, struct http_request *req, struct uh_path_info *pi)
+void uh_file_request(struct client *cl, struct http_request *req, struct path_info *pi)
{
int fd, rlen;
char buf[UH_LIMIT_MSGHEAD];
/* pump file data */
while( (rlen = read(fd, buf, sizeof(buf))) > 0 )
{
- uh_http_send(cl, req, buf, rlen);
+ if( uh_http_send(cl, req, buf, rlen) < 0 )
+ break;
}
/* send trailer in chunked mode */