Skip to content

Commit 3da0a3e

Browse files
committed
Add method on logs
1 parent ff9dad6 commit 3da0a3e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/ngx_http_redirectionio_protocol.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
const char COMMAND_MATCH_NAME[] = "MATCH_WITH_RESPONSE";
55
const char COMMAND_MATCH_QUERY[] = "{ \"project_id\": \"%V\", \"request_uri\": \"%V\", \"host\": \"%V\" }";
66
const char COMMAND_LOG_NAME[] = "LOG";
7-
const char COMMAND_LOG_QUERY[] = "{ \"project_id\": \"%V\", \"request_uri\": \"%V\", \"host\": \"%V\", \"rule_id\": \"%V\", \"target\": \"%V\", \"status_code\": %d, \"user_agent\": \"%V\", \"referer\": \"%V\" }";
7+
const char COMMAND_LOG_QUERY[] = "{ \"project_id\": \"%V\", \"request_uri\": \"%V\", \"host\": \"%V\", \"rule_id\": \"%V\", \"target\": \"%V\", \"status_code\": %d, \"user_agent\": \"%V\", \"referer\": \"%V\", \"method\": \"%V\" }";
88
const char COMMAND_FILTER_HEADER_NAME[] = "FILTER_HEADER";
99
const char COMMAND_FILTER_BODY_NAME[] = "FILTER_BODY";
1010

@@ -48,7 +48,8 @@ void ngx_http_redirectionio_protocol_send_log(ngx_connection_t *c, ngx_http_redi
4848
+ log->location.len
4949
+ log->user_agent.len
5050
+ log->referer.len
51-
- 16 // 8 * 2 (%x) characters replaced with values
51+
+ log->method.len
52+
- 18 // 9 * 2 (%x) characters replaced with values
5253
;
5354

5455
dst = (u_char *) ngx_pcalloc(c->pool, wlen);
@@ -63,7 +64,8 @@ void ngx_http_redirectionio_protocol_send_log(ngx_connection_t *c, ngx_http_redi
6364
&log->location,
6465
log->status,
6566
&log->user_agent,
66-
&log->referer
67+
&log->referer,
68+
&log->method
6769
);
6870

6971
v = (ngx_str_t) { wlen, dst };
@@ -106,6 +108,8 @@ ngx_http_redirectionio_log_t* ngx_http_redirectionio_protocol_create_log(ngx_htt
106108
ngx_str_copy(&r->headers_out.location->value, &log->location);
107109
}
108110

111+
ngx_str_copy(&r->method_name, &log->method);
112+
109113
return log;
110114
}
111115

src/ngx_http_redirectionio_protocol.h

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ typedef struct {
1515
ngx_str_t location;
1616
ngx_str_t user_agent;
1717
ngx_str_t referer;
18+
ngx_str_t method;
1819
} ngx_http_redirectionio_log_t;
1920

2021
void ngx_http_redirectionio_protocol_send_match(ngx_connection_t *c, ngx_http_request_t *r, ngx_str_t *project_key);

0 commit comments

Comments
 (0)