make uh_path_lookup static
[project/uhttpd.git] / client.c
index 9e387c7..a28067e 100644 (file)
--- a/client.c
+++ b/client.c
@@ -51,12 +51,6 @@ void uh_http_header(struct client *cl, int code, const char *summary)
                code, summary, conn, enc);
 }
 
-static void uh_client_error_header(struct client *cl, int code, const char *summary)
-{
-       uh_http_header(cl, code, summary);
-       ustream_printf(cl->us, "Content-Type: text/plain\r\n\r\n");
-}
-
 static void uh_connection_close(struct client *cl)
 {
        cl->state = CLIENT_STATE_DONE;
@@ -69,6 +63,7 @@ static void uh_dispatch_done(struct client *cl)
        if (cl->dispatch_free)
                cl->dispatch_free(cl);
        cl->dispatch_free = NULL;
+       cl->dispatch_close_fds = NULL;
 }
 
 void uh_request_done(struct client *cl)
@@ -92,18 +87,23 @@ uh_client_error(struct client *cl, int code, const char *summary, const char *fm
 {
        va_list arg;
 
-       uh_client_error_header(cl, code, summary);
+       uh_http_header(cl, code, summary);
+       ustream_printf(cl->us, "Content-Type: text/html\r\n\r\n");
+
+       uh_chunk_printf(cl, "<h1>%s</h1>", summary);
 
-       va_start(arg, fmt);
-       uh_chunk_vprintf(cl, fmt, arg);
-       va_end(arg);
+       if (fmt) {
+               va_start(arg, fmt);
+               uh_chunk_vprintf(cl, fmt, arg);
+               va_end(arg);
+       }
 
        uh_request_done(cl);
 }
 
 static void uh_header_error(struct client *cl, int code, const char *summary)
 {
-       uh_client_error(cl, code, summary, "%s", summary);
+       uh_client_error(cl, code, summary, NULL);
        uh_connection_close(cl);
 }
 
@@ -330,3 +330,16 @@ void uh_accept_client(int fd)
        n_clients++;
        cl->id = client_id++;
 }
+
+void uh_close_fds(void)
+{
+       struct client *cl;
+
+       uloop_done();
+       uh_close_listen_fds();
+       list_for_each_entry(cl, &clients, list) {
+               close(cl->sfd.fd.fd);
+               if (cl->dispatch_close_fds)
+                       cl->dispatch_close_fds(cl);
+       }
+}