/* Returns NULL on error.
** NB: improperly encoded URL should give client 400 [Bad Syntax]; returning
** NULL here causes 404 [Not Found], but that's not too unreasonable. */
-static struct path_info *
+struct path_info *
uh_path_lookup(struct client *cl, const char *url)
{
static char path_phys[PATH_MAX];
url with trailing slash appended */
if (!slash) {
uh_http_header(cl, 302, "Found");
- ustream_printf(cl->us, "Content-Length: 0\r\n");
+ if (!uh_use_chunked(cl))
+ ustream_printf(cl->us, "Content-Length: 0\r\n");
ustream_printf(cl->us, "Location: %s%s%s\r\n\r\n",
&path_phys[docroot_len],
p.query ? "?" : "",
char *url = blobmsg_data(blob_data(cl->hdr.head));
char *error_handler;
+ blob_buf_init(&cl->hdr_response, 0);
url = uh_handle_alias(url);
+ uh_handler_run(cl, &url, false);
+ if (!url)
+ return;
+
req->redirect_status = 200;
d = dispatch_find(url, NULL);
if (d)
if (__handle_file_request(cl, url))
return;
+ if (uh_handler_run(cl, &url, true) &&
+ (!url || __handle_file_request(cl, url)))
+ return;
+
req->redirect_status = 404;
if (conf.error_handler) {
error_handler = alloca(strlen(conf.error_handler) + 1);