summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fileserv.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/fileserv.c b/src/fileserv.c
index 58262c3..568ba37 100644
--- a/src/fileserv.c
+++ b/src/fileserv.c
@@ -506,12 +506,18 @@ get_file_resp(struct MHD_Connection *conn, char const *url, FILE_RESP *resp)
fstat(resp->fd, &resp->st);
resp->type = get_file_type(resp->file_name);
return MHD_HTTP_OK;
}
+static inline char const *
+safestr(char const *s)
+{
+ return s ? s : "-";
+}
+
void
http_log(struct MHD_Connection *connection,
char const *method, char const *url,
int status, struct stat const *st)
{
char *ipstr;
@@ -534,15 +540,14 @@ http_log(struct MHD_Connection *connection,
t = time(NULL);
tm = localtime(&t);
strftime(tbuf, sizeof(tbuf), "[%d/%b/%Y:%H:%M:%S %z]", tm);
info("%s %s - - %s \"%s %s\" %3d %lu \"%s\" \"%s\"",
- host, ipstr, tbuf, method, url, status, st ? st->st_size : 0,
- referer ? referer : "",
- user_agent ? user_agent : "");
+ safestr(host), ipstr, tbuf, method, url, status,
+ st ? st->st_size : 0, safestr(referer), safestr(user_agent));
free(ipstr);
}
static int
http_redirect(struct MHD_Connection *connection,
char const *method, char const *url,

Return to:

Send suggestions and report system problems to the System administrator.