- /*
- * Check the file extensionlessly:
- */
- if(!strchr(p, '.') && ((dir = opendir(path)) != NULL)) {
- while((dent = readdir(dir)) != NULL) {
- buf = sprintf3("%s/%s", path, dent->d_name);
- if((p3 = strchr(dent->d_name, '.')) != NULL)
- *p3 = 0;
- if(strcmp(dent->d_name, p))
- continue;
- if(stat(buf, &sb))
- continue;
- if(!S_ISREG(sb.st_mode))
- continue;
- tmp = path;
- path = sstrdup(buf);
- free(tmp);
- break;
+static int checkpath(struct hthead *req, int fd, char *path, char *rest);
+
+static int checkentry(struct hthead *req, int fd, char *path, char *rest, char *el)
+{
+ struct stat sb;
+ char *newpath;
+ int rv;
+
+ if(!el == '.') {
+ simpleerror(fd, 404, "Not Found", "The requested URL has no corresponding resource.");
+ return(1);
+ }
+ if(!stat(sprintf3("%s/%s", path, el), &sb)) {
+ if(S_ISDIR(sb.st_mode)) {
+ if(!*rest) {
+ stdredir(req, fd, 301, sprintf3("%s/", el));
+ return(1);