#include <time.h>
#include <strings.h>
#include <dirent.h>
+#include <stdint.h>
#include <libubox/blobmsg.h>
static const char * uh_file_mktag(struct stat *s, char *buf, int len)
{
- snprintf(buf, len, "\"%x-%x-%x\"",
- (unsigned int) s->st_ino,
- (unsigned int) s->st_size,
- (unsigned int) s->st_mtime);
+ snprintf(buf, len, "\"%" PRIx64 "-%" PRIx64 "-%" PRIx64 "\"",
+ s->st_ino, s->st_size, (uint64_t)s->st_mtime);
return buf;
}
bool dir = !!(files[i]->d_type & DT_DIR);
if (name[0] == '.' && name[1] == 0)
- continue;
+ goto next;
sprintf(file, "%s", name);
if (stat(local_path, &s))
- continue;
+ goto next;
if (!dir) {
suffix = "";
}
if (!(s.st_mode & mode))
- continue;
+ goto next;
uh_chunk_printf(cl,
"<li><strong><a href='%s%s%s'>%s</a>%s"
type, s.st_size / 1024.0);
*file = 0;
+next:
free(files[i]);
}
}
ustream_printf(cl->us, "Content-Type: %s\r\n",
uh_file_mime_lookup(pi->name));
- ustream_printf(cl->us, "Content-Length: %i\r\n\r\n",
+ ustream_printf(cl->us, "Content-Length: %" PRIu64 "\r\n\r\n",
pi->stat.st_size);
if (fd < 0)
goto error;
+ req->respond_chunked = false;
cl->dispatch.file.hdr = tb;
uh_file_data(cl, pi, fd);
cl->dispatch.file.hdr = NULL;
dr = list_first_entry(&pending_requests, struct deferred_request, list);
list_del(&dr->list);
+ cl = dr->cl;
dr->called = true;
- uh_invoke_script(dr->cl, dr->d, dr->path ? &dr->pi : NULL);
+ cl->dispatch.data_blocked = false;
+ uh_invoke_script(cl, dr->d, dr->path ? &dr->pi : NULL);
+ client_poll_post_data(cl);
}
}
}
cl->dispatch.req_data = dr;
+ cl->dispatch.data_blocked = true;
dr->cl = cl;
dr->d = d;
list_add(&dr->list, &pending_requests);