Skip to content

Commit 8872a45

Browse files
authored
feat(vars): add http_via to indexed variables (#114)
1 parent 921e593 commit 8872a45

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ index *commonly used variables* as follows:
101101
- `$http_proxy_connection`
102102
- `$http_te`
103103
- `$http_upgrade`
104+
- `$http_via`
104105
- `$http_x_forwarded_for`
105106
- `$http_x_forwarded_host`
106107
- `$http_x_forwarded_path`

src/ngx_http_lua_kong_var_index.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ static ngx_str_t default_vars[] = {
3535
ngx_string("http_proxy_connection"),
3636
ngx_string("http_te"),
3737
ngx_string("http_upgrade"),
38+
ngx_string("http_via"),
3839

3940
/* http request headers */
4041
ngx_string("http_x_forwarded_for"),
@@ -333,5 +334,3 @@ ngx_http_lua_kong_ffi_var_set_by_index(ngx_http_request_t *r, ngx_uint_t index,
333334
*err = "no memory";
334335
return NGX_ERROR;
335336
}
336-
337-

t/006-default_indexed-var.t

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use Test::Nginx::Socket::Lua;
99

1010
repeat_each(2);
1111

12-
plan tests => repeat_each() * (blocks() * 8) - 10;
12+
plan tests => repeat_each() * (blocks() * 8) - 8;
1313

1414
$ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
1515

@@ -117,7 +117,8 @@ get variable value '/test' by index
117117
ngx.var.http_proxy, " ",
118118
ngx.var.http_proxy_connection, " ",
119119
ngx.var.http_te, " ",
120-
ngx.var.http_upgrade
120+
ngx.var.http_upgrade, " ",
121+
ngx.var.http_via
121122
)
122123
}
123124
}
@@ -132,8 +133,9 @@ proxy: 111
132133
proxy-connection: 222
133134
te: 333
134135
upgrade: 444
136+
via: 1.1 kong
135137
--- response_body
136-
auth close test.com 1 111 222 333 444
138+
auth close test.com 1 111 222 333 444 1.1 kong
137139
--- error_log
138140
get variable value 'auth' by index
139141
get variable value 'close' by index
@@ -143,6 +145,7 @@ get variable value '111' by index
143145
get variable value '222' by index
144146
get variable value '333' by index
145147
get variable value '444' by index
148+
get variable value '1.1 kong' by index
146149
--- no_error_log
147150
[error]
148151
[crit]

0 commit comments

Comments
 (0)