Klaus Demo nginx / c7fcd1e
Merge of r4686, r4687: $status variable. Contains response status code as a 3-digit integer (with leading zeroes if necessary), or one of the following values: 000 - response status code has not yet been assigned 009 - HTTP/0.9 request is being processed Maxim Dounin 10 years ago
2 changed file(s) with 40 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
583583 status = r->headers_out.status;
584584
585585 } else if (r->http_version == NGX_HTTP_VERSION_9) {
586 *buf++ = '0';
587 *buf++ = '0';
588 *buf++ = '9';
589 return buf;
586 status = 9;
590587
591588 } else {
592589 status = 0;
7575 static ngx_int_t ngx_http_variable_request_body(ngx_http_request_t *r,
7676 ngx_http_variable_value_t *v, uintptr_t data);
7777 static ngx_int_t ngx_http_variable_request_body_file(ngx_http_request_t *r,
78 ngx_http_variable_value_t *v, uintptr_t data);
79 static ngx_int_t ngx_http_variable_status(ngx_http_request_t *r,
7880 ngx_http_variable_value_t *v, uintptr_t data);
7981
8082 static ngx_int_t ngx_http_variable_sent_content_type(ngx_http_request_t *r,
224226 ngx_http_variable_request_body_file,
225227 0, 0, 0 },
226228
229 { ngx_string("status"), NULL,
230 ngx_http_variable_status, 0,
231 NGX_HTTP_VAR_NOCACHEABLE, 0 },
232
227233 { ngx_string("sent_http_content_type"), NULL,
228234 ngx_http_variable_sent_content_type, 0, 0, 0 },
229235
14491455 v->no_cacheable = 0;
14501456 v->not_found = 0;
14511457 v->data = p;
1458
1459 return NGX_OK;
1460 }
1461
1462
1463 static ngx_int_t
1464 ngx_http_variable_status(ngx_http_request_t *r,
1465 ngx_http_variable_value_t *v, uintptr_t data)
1466 {
1467 ngx_uint_t status;
1468
1469 v->data = ngx_pnalloc(r->pool, NGX_INT_T_LEN);
1470 if (v->data == NULL) {
1471 return NGX_ERROR;
1472 }
1473
1474 if (r->err_status) {
1475 status = r->err_status;
1476
1477 } else if (r->headers_out.status) {
1478 status = r->headers_out.status;
1479
1480 } else if (r->http_version == NGX_HTTP_VERSION_9) {
1481 status = 9;
1482
1483 } else {
1484 status = 0;
1485 }
1486
1487 v->len = ngx_sprintf(v->data, "%03ui", status) - v->data;
1488 v->valid = 1;
1489 v->no_cacheable = 0;
1490 v->not_found = 0;
14521491
14531492 return NGX_OK;
14541493 }