summaryrefslogtreecommitdiff
path: root/plugin/protocol/http/src
diff options
context:
space:
mode:
authorLu Qiuwen <[email protected]>2018-10-24 20:53:29 +0800
committerLu Qiuwen <[email protected]>2018-10-24 20:53:29 +0800
commitf87e21d3231ead061b53d6235bd4339e8aaf7297 (patch)
tree5b21bcb385849759b9d27b73df7a9d6125f56cad /plugin/protocol/http/src
parent62b80891669b7d1ca06c2d2cd7f93d7d47b543c8 (diff)
改进HTTP访问日志格式
Diffstat (limited to 'plugin/protocol/http/src')
-rw-r--r--plugin/protocol/http/src/http_half.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/plugin/protocol/http/src/http_half.cpp b/plugin/protocol/http/src/http_half.cpp
index 3ef8b2b..beed689 100644
--- a/plugin/protocol/http/src/http_half.cpp
+++ b/plugin/protocol/http/src/http_half.cpp
@@ -1091,17 +1091,15 @@ void __write_access_log(struct http_session_private * hs_private)
}
/* Content Type */
- const char * __str_cont_type = resp_spec ? resp_spec->content_type : "-";
- /* Content Length */
- const char * __str_cont_length = resp_spec ? resp_spec->content_length : "-";
+ const char * __str_cont_type = resp_spec ? resp_spec->content_type != NULL ? resp_spec->content_type : "-" : "-";
/* Content Encoding */
- const char * __str_cont_encoding = resp_spec ? resp_spec->content_encoding : "-";
+ const char * __str_cont_encoding = resp_spec ? resp_spec->content_encoding != NULL ? resp_spec->content_encoding: "-" : "-";
/* Upgrade Tag */
- const char * __str_upgrade = response->is_upgrade ? "UPGRADE" : "-";
+ const char * __str_upgrade = response ? response->is_upgrade ? "UPGRADE" : "-" : "-";
char * __access_log;
- asprintf(&__access_log, "%s %s %s %s %s %s %s", __str_method,
- __str_url, __str_resp_code, __str_cont_type, __str_cont_length, __str_cont_encoding, __str_upgrade);
+ asprintf(&__access_log, "%d %s %s HTTP/%d.%d %s %s %s %s", hs_private->hs_public.session_id, __str_method,
+ __str_url, request->major, request->minor, __str_resp_code, __str_cont_type, __str_cont_encoding, __str_upgrade);
const struct tfe_stream * stream = hs_private->hc_private->stream;
tfe_stream_write_access_log(stream, RLOG_LV_INFO, "%s", __access_log);