@@ -9,7 +9,7 @@ use Test::Nginx::Socket;
9
9
10
10
repeat_each(2);
11
11
12
- plan tests => repeat_each() * (2 * blocks() + 10 );
12
+ plan tests => repeat_each() * (2 * blocks() + 14 );
13
13
14
14
# no_diff();
15
15
no_long_string();
@@ -1155,3 +1155,94 @@ X-Real-IP: 8.8.4.4
1155
1155
--- no_error_log
1156
1156
[error]
1157
1157
1158
+
1159
+
1160
+ === TEST 37: clear Via
1161
+ --- config
1162
+ location /t {
1163
+ rewrite_by_lua '
1164
+ ngx.req.set_header("Via", nil)
1165
+ ';
1166
+ echo "Via: $http_via";
1167
+ }
1168
+ --- request
1169
+ GET /t
1170
+ --- more_headers
1171
+ Via: 1.0 fred, 1.1 nowhere.com (Apache/1.1)
1172
+
1173
+ --- stap
1174
+ F(ngx_http_lua_rewrite_by_chunk) {
1175
+ if (@defined($r->headers_in->via) && $r->headers_in->via) {
1176
+ printf("rewrite: via: %s\n",
1177
+ user_string_n($r->headers_in->via->value->data,
1178
+ $r->headers_in->via->value->len))
1179
+ } else {
1180
+ println("rewrite: no via")
1181
+ }
1182
+ }
1183
+
1184
+ F(ngx_http_core_content_phase) {
1185
+ if (@defined($r->headers_in->via) && $r->headers_in->via) {
1186
+ printf("content: via: %s\n",
1187
+ user_string_n($r->headers_in->via->value->data,
1188
+ $r->headers_in->via->value->len))
1189
+ } else {
1190
+ println("content: no via")
1191
+ }
1192
+ }
1193
+
1194
+ --- stap_out
1195
+ rewrite: via: 1.0 fred, 1.1 nowhere.com (Apache/1.1)
1196
+ content: no via
1197
+
1198
+ --- response_body
1199
+ Via:
1200
+
1201
+ --- no_error_log
1202
+ [error]
1203
+
1204
+
1205
+
1206
+ === TEST 38: set custom Via
1207
+ --- config
1208
+ location /t {
1209
+ rewrite_by_lua '
1210
+ ngx.req.set_header("Via", "1.0 fred, 1.1 nowhere.com (Apache/1.1)")
1211
+ ';
1212
+ echo "Via: $http_via";
1213
+ }
1214
+ --- request
1215
+ GET /t
1216
+
1217
+ --- stap
1218
+ F(ngx_http_lua_rewrite_by_chunk) {
1219
+ if (@defined($r->headers_in->via) && $r->headers_in->via) {
1220
+ printf("rewrite: via: %s\n",
1221
+ user_string_n($r->headers_in->via->value->data,
1222
+ $r->headers_in->via->value->len))
1223
+ } else {
1224
+ println("rewrite: no via")
1225
+ }
1226
+
1227
+ }
1228
+
1229
+ F(ngx_http_core_content_phase) {
1230
+ if (@defined($r->headers_in->via) && $r->headers_in->via) {
1231
+ printf("content: via: %s\n",
1232
+ user_string_n($r->headers_in->via->value->data,
1233
+ $r->headers_in->via->value->len))
1234
+ } else {
1235
+ println("content: no via")
1236
+ }
1237
+ }
1238
+
1239
+ --- stap_out
1240
+ rewrite: no via
1241
+ content: via: 1.0 fred, 1.1 nowhere.com (Apache/1.1)
1242
+
1243
+ --- response_body
1244
+ Via: 1.0 fred, 1.1 nowhere.com (Apache/1.1)
1245
+
1246
+ --- no_error_log
1247
+ [error]
1248
+
0 commit comments