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;
if (cl->dispatch_free)
cl->dispatch_free(cl);
cl->dispatch_free = NULL;
+ cl->dispatch_close_fds = NULL;
}
void uh_request_done(struct client *cl)
{
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);
}
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);
+ }
+}