comparison src/http/ngx_http_variables.c @ 678:981b4c44593b NGINX_1_3_2

nginx 1.3.2 *) Change: the "single" parameter of the "keepalive" directive is now ignored. *) Change: SSL compression is now disabled when using all versions of OpenSSL, including ones prior to 1.0.0. *) Feature: it is now possible to use the "ip_hash" directive to balance IPv6 clients. *) Feature: the $status variable can now be used not only in the "log_format" directive. *) Bugfix: a segmentation fault might occur in a worker process on shutdown if the "resolver" directive was used. *) Bugfix: a segmentation fault might occur in a worker process if the ngx_http_mp4_module was used. *) Bugfix: in the ngx_http_mp4_module. *) Bugfix: a segmentation fault might occur in a worker process if conflicting wildcard server names were used. *) Bugfix: nginx might be terminated abnormally on a SIGBUS signal on ARM platform. *) Bugfix: an alert "sendmsg() failed (9: Bad file number)" on HP-UX while reconfiguration.
author Igor Sysoev <http://sysoev.ru>
date Tue, 26 Jun 2012 00:00:00 +0400
parents bfa81a0490a2
children b5b7eea22fda
comparison
equal deleted inserted replaced
677:47f0934d8824 678:981b4c44593b
74 static ngx_int_t ngx_http_variable_request_completion(ngx_http_request_t *r, 74 static ngx_int_t ngx_http_variable_request_completion(ngx_http_request_t *r,
75 ngx_http_variable_value_t *v, uintptr_t data); 75 ngx_http_variable_value_t *v, uintptr_t data);
76 static ngx_int_t ngx_http_variable_request_body(ngx_http_request_t *r, 76 static ngx_int_t ngx_http_variable_request_body(ngx_http_request_t *r,
77 ngx_http_variable_value_t *v, uintptr_t data); 77 ngx_http_variable_value_t *v, uintptr_t data);
78 static ngx_int_t ngx_http_variable_request_body_file(ngx_http_request_t *r, 78 static ngx_int_t ngx_http_variable_request_body_file(ngx_http_request_t *r,
79 ngx_http_variable_value_t *v, uintptr_t data);
80 static ngx_int_t ngx_http_variable_status(ngx_http_request_t *r,
79 ngx_http_variable_value_t *v, uintptr_t data); 81 ngx_http_variable_value_t *v, uintptr_t data);
80 82
81 static ngx_int_t ngx_http_variable_sent_content_type(ngx_http_request_t *r, 83 static ngx_int_t ngx_http_variable_sent_content_type(ngx_http_request_t *r,
82 ngx_http_variable_value_t *v, uintptr_t data); 84 ngx_http_variable_value_t *v, uintptr_t data);
83 static ngx_int_t ngx_http_variable_sent_content_length(ngx_http_request_t *r, 85 static ngx_int_t ngx_http_variable_sent_content_length(ngx_http_request_t *r,
130 #if (NGX_HTTP_GZIP) 132 #if (NGX_HTTP_GZIP)
131 { ngx_string("http_via"), NULL, ngx_http_variable_header, 133 { ngx_string("http_via"), NULL, ngx_http_variable_header,
132 offsetof(ngx_http_request_t, headers_in.via), 0, 0 }, 134 offsetof(ngx_http_request_t, headers_in.via), 0, 0 },
133 #endif 135 #endif
134 136
135 #if (NGX_HTTP_PROXY || NGX_HTTP_REALIP) 137 #if (NGX_HTTP_X_FORWARDED_FOR)
136 { ngx_string("http_x_forwarded_for"), NULL, ngx_http_variable_header, 138 { ngx_string("http_x_forwarded_for"), NULL, ngx_http_variable_header,
137 offsetof(ngx_http_request_t, headers_in.x_forwarded_for), 0, 0 }, 139 offsetof(ngx_http_request_t, headers_in.x_forwarded_for), 0, 0 },
138 #endif 140 #endif
139 141
140 { ngx_string("http_cookie"), NULL, ngx_http_variable_headers, 142 { ngx_string("http_cookie"), NULL, ngx_http_variable_headers,
222 0, 0, 0 }, 224 0, 0, 0 },
223 225
224 { ngx_string("request_body_file"), NULL, 226 { ngx_string("request_body_file"), NULL,
225 ngx_http_variable_request_body_file, 227 ngx_http_variable_request_body_file,
226 0, 0, 0 }, 228 0, 0, 0 },
229
230 { ngx_string("status"), NULL,
231 ngx_http_variable_status, 0,
232 NGX_HTTP_VAR_NOCACHEABLE, 0 },
227 233
228 { ngx_string("sent_http_content_type"), NULL, 234 { ngx_string("sent_http_content_type"), NULL,
229 ngx_http_variable_sent_content_type, 0, 0, 0 }, 235 ngx_http_variable_sent_content_type, 0, 0, 0 },
230 236
231 { ngx_string("sent_http_content_length"), NULL, 237 { ngx_string("sent_http_content_length"), NULL,
1448 v->len = ngx_sprintf(p, "%O", sent) - p; 1454 v->len = ngx_sprintf(p, "%O", sent) - p;
1449 v->valid = 1; 1455 v->valid = 1;
1450 v->no_cacheable = 0; 1456 v->no_cacheable = 0;
1451 v->not_found = 0; 1457 v->not_found = 0;
1452 v->data = p; 1458 v->data = p;
1459
1460 return NGX_OK;
1461 }
1462
1463
1464 static ngx_int_t
1465 ngx_http_variable_status(ngx_http_request_t *r,
1466 ngx_http_variable_value_t *v, uintptr_t data)
1467 {
1468 ngx_uint_t status;
1469
1470 v->data = ngx_pnalloc(r->pool, NGX_INT_T_LEN);
1471 if (v->data == NULL) {
1472 return NGX_ERROR;
1473 }
1474
1475 if (r->err_status) {
1476 status = r->err_status;
1477
1478 } else if (r->headers_out.status) {
1479 status = r->headers_out.status;
1480
1481 } else if (r->http_version == NGX_HTTP_VERSION_9) {
1482 status = 9;
1483
1484 } else {
1485 status = 0;
1486 }
1487
1488 v->len = ngx_sprintf(v->data, "%03ui", status) - v->data;
1489 v->valid = 1;
1490 v->no_cacheable = 0;
1491 v->not_found = 0;
1453 1492
1454 return NGX_OK; 1493 return NGX_OK;
1455 } 1494 }
1456 1495
1457 1496