or the request completed. Turn the old log message into a debug message.
ok doug@
-/* $OpenBSD: httpd.h,v 1.29 2014/08/01 21:59:56 reyk Exp $ */
+/* $OpenBSD: httpd.h,v 1.30 2014/08/01 22:24:05 reyk Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
void server_write(struct bufferevent *, void *);
void server_read(struct bufferevent *, void *);
void server_error(struct bufferevent *, short, void *);
+void server_log(struct client *);
void server_close(struct client *, const char *);
void server_dump(struct client *, const void *, size_t);
int server_client_cmp(struct client *, struct client *);
-/* $OpenBSD: server.c,v 1.20 2014/08/01 21:59:56 reyk Exp $ */
+/* $OpenBSD: server.c,v 1.21 2014/08/01 22:24:05 reyk Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
__func__, server_inflight, why);
}
+void
+server_log(struct client *clt)
+{
+ char *ptr = NULL;
+
+ if (!EVBUFFER_LENGTH(clt->clt_log))
+ return;
+
+ while ((ptr = evbuffer_readline(clt->clt_log)) != NULL) {
+ log_info("%s", ptr);
+ free(ptr);
+ }
+}
+
void
server_close(struct client *clt, const char *msg)
{
char ibuf[MAXHOSTNAMELEN], obuf[MAXHOSTNAMELEN];
- char *ptr = NULL;
struct server *srv = clt->clt_srv;
struct server_config *srv_conf = clt->clt_srv_conf;
+ extern int debug;
SPLAY_REMOVE(client_tree, &srv->srv_clients, clt);
if (clt->clt_srvbev != NULL)
bufferevent_disable(clt->clt_srvbev, EV_READ|EV_WRITE);
- if (msg != NULL) {
+ server_log(clt);
+
+ if (debug && msg != NULL) {
memset(&ibuf, 0, sizeof(ibuf));
memset(&obuf, 0, sizeof(obuf));
(void)print_host(&clt->clt_ss, ibuf, sizeof(ibuf));
(void)server_http_host(&clt->clt_srv_ss, obuf, sizeof(obuf));
- if (EVBUFFER_LENGTH(clt->clt_log) &&
- evbuffer_add_printf(clt->clt_log, "\r\n") != -1)
- ptr = evbuffer_readline(clt->clt_log);
- log_info("server %s, "
+ log_debug("server %s, "
"client %d (%d active), %s:%u -> %s, "
- "%s%s%s", srv_conf->name, clt->clt_id, server_clients,
- ibuf, ntohs(clt->clt_port), obuf, msg,
- ptr == NULL ? "" : ",", ptr == NULL ? "" : ptr);
- if (ptr != NULL)
- free(ptr);
+ "%s", srv_conf->name, clt->clt_id, server_clients,
+ ibuf, ntohs(clt->clt_port), obuf, msg);
}
if (clt->clt_bev != NULL)
-/* $OpenBSD: server_http.c,v 1.26 2014/08/01 21:51:02 doug Exp $ */
+/* $OpenBSD: server_http.c,v 1.27 2014/08/01 22:24:05 reyk Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
clt->clt_chunk = 0;
clt->clt_bev->readcb = server_read_http;
clt->clt_srv_conf = &srv->srv_conf;
+
+ server_log(clt);
}
void
*/
switch (srv_conf->logformat) {
case LOG_FORMAT_COMMON:
- log_info("%s %s - - [%s] \"%s %s%s%s%s%s\" %03d %zu",
+ if (evbuffer_add_printf(clt->clt_log,
+ "%s %s - - [%s] \"%s %s%s%s%s%s\" %03d %zu\n",
srv_conf->name, ip, tstamp,
server_httpmethod_byid(desc->http_method),
desc->http_path == NULL ? "" : desc->http_path,
desc->http_query == NULL ? "" : desc->http_query,
desc->http_version == NULL ? "" : " ",
desc->http_version == NULL ? "" : desc->http_version,
- code, len);
+ code, len) == -1)
+ return (-1);
break;
case LOG_FORMAT_COMBINED:
agent->kv_value == NULL)
agent = NULL;
- log_info("%s %s - - [%s] \"%s %s%s%s%s%s\" %03d %zu"
- " \"%s\" \"%s\"",
+ if (evbuffer_add_printf(clt->clt_log,
+ "%s %s - - [%s] \"%s %s%s%s%s%s\" %03d %zu \"%s\" \"%s\"\n",
srv_conf->name, ip, tstamp,
server_httpmethod_byid(desc->http_method),
desc->http_path == NULL ? "" : desc->http_path,
desc->http_version == NULL ? "" : desc->http_version,
code, len,
referrer == NULL ? "" : referrer->kv_value,
- agent == NULL ? "" : agent->kv_value);
+ agent == NULL ? "" : agent->kv_value) == -1)
+ return (-1);
break;
- default:
+ case LOG_FORMAT_NONE:
return (-1);
}