From 372716a27719cd88897b5a4b95332b0101d27ca2 Mon Sep 17 00:00:00 2001 From: Jianhui Zhao Date: Sat, 25 Nov 2017 23:48:09 +0800 Subject: [PATCH] Optimize code Signed-off-by: Jianhui Zhao --- src/log.c | 4 ++-- src/uhttp.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/log.c b/src/log.c index 70cbae5..8ef75e7 100755 --- a/src/log.c +++ b/src/log.c @@ -19,10 +19,10 @@ void __uh_log(const char *filename, int line, int priority, const char *format, syslog(priority, "%s", buf); #if (UHTTP_DEBUG) - fprintf(stderr, "%s", buf); + fprintf(stderr, "%s\n", buf); #else if (priority == LOG_ERR) - fprintf(stderr, "%s", buf); + fprintf(stderr, "%s\n", buf); #endif } diff --git a/src/uhttp.c b/src/uhttp.c index 9763c62..d65e139 100755 --- a/src/uhttp.c +++ b/src/uhttp.c @@ -73,7 +73,7 @@ static int on_url(http_parser *parser, const char *at, size_t len) struct uh_connection *con = container_of(parser, struct uh_connection, parser); struct http_parser_url url; - uh_log_debug("Url:[%.*s]\n", (int)len, at); + uh_log_debug("Url:[%.*s]", (int)len, at); con->req.url.at = at; con->req.url.len = len; @@ -105,7 +105,7 @@ static int on_header_field(http_parser *parser, const char *at, size_t len) struct uh_connection *con = container_of(parser, struct uh_connection, parser); struct uh_header *header = con->req.header; - uh_log_debug("header field:[%.*s]\n", (int)len, at); + uh_log_debug("header field:[%.*s]", (int)len, at); header[con->req.header_num].field.at = at; header[con->req.header_num].field.len = len; @@ -118,7 +118,7 @@ static int on_header_value(http_parser *parser, const char *at, size_t len) struct uh_connection *con = container_of(parser, struct uh_connection, parser); struct uh_header *header = con->req.header; - uh_log_debug("header value:[%.*s]\n", (int)len, at); + uh_log_debug("header value:[%.*s]", (int)len, at); header[con->req.header_num].value.at = at; header[con->req.header_num].value.len = len; @@ -143,7 +143,7 @@ static int on_body(http_parser *parser, const char *at, size_t len) { struct uh_connection *con = container_of(parser, struct uh_connection, parser); - uh_log_debug("body:[%.*s]\n", (int)len, at); + uh_log_debug("body:[%.*s]", (int)len, at); if (!con->req.body.at) con->req.body.at = at; @@ -230,7 +230,7 @@ handshake_done: buf->len += len; - uh_log_debug("read:[%.*s]\n", len, base); + uh_log_debug("read:[%.*s]", len, base); if (!(con->flags & UH_CON_PARSERING)) { if (!memmem(buf->base, buf->len, "\r\n\r\n", 4)) {