[nginx] svn commit: r4727 - in branches/stable-1.2: . src/http src/http/modules
mdounin at mdounin.ru
mdounin at mdounin.ru
Mon Jul 2 16:53:36 UTC 2012
Author: mdounin
Date: 2012-07-02 16:53:36 +0000 (Mon, 02 Jul 2012)
New Revision: 4727
URL: http://trac.nginx.org/nginx/changeset/4727/nginx
Log:
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
Modified:
branches/stable-1.2/
branches/stable-1.2/src/http/modules/ngx_http_log_module.c
branches/stable-1.2/src/http/ngx_http_variables.c
Index: branches/stable-1.2
===================================================================
--- branches/stable-1.2 2012-07-02 16:51:02 UTC (rev 4726)
+++ branches/stable-1.2 2012-07-02 16:53:36 UTC (rev 4727)
Property changes on: branches/stable-1.2
___________________________________________________________________
Modified: svn:mergeinfo
## -1 +1 ##
-/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4685,4692,4694-4696,4699,4704-4705
+/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4687,4692,4694-4696,4699,4704-4705
\ No newline at end of property
Modified: branches/stable-1.2/src/http/modules/ngx_http_log_module.c
===================================================================
--- branches/stable-1.2/src/http/modules/ngx_http_log_module.c 2012-07-02 16:51:02 UTC (rev 4726)
+++ branches/stable-1.2/src/http/modules/ngx_http_log_module.c 2012-07-02 16:53:36 UTC (rev 4727)
@@ -584,10 +584,7 @@
status = r->headers_out.status;
} else if (r->http_version == NGX_HTTP_VERSION_9) {
- *buf++ = '0';
- *buf++ = '0';
- *buf++ = '9';
- return buf;
+ status = 9;
} else {
status = 0;
Modified: branches/stable-1.2/src/http/ngx_http_variables.c
===================================================================
--- branches/stable-1.2/src/http/ngx_http_variables.c 2012-07-02 16:51:02 UTC (rev 4726)
+++ branches/stable-1.2/src/http/ngx_http_variables.c 2012-07-02 16:53:36 UTC (rev 4727)
@@ -77,6 +77,8 @@
ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_request_body_file(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_http_variable_status(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_sent_content_type(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
@@ -225,6 +227,10 @@
ngx_http_variable_request_body_file,
0, 0, 0 },
+ { ngx_string("status"), NULL,
+ ngx_http_variable_status, 0,
+ NGX_HTTP_VAR_NOCACHEABLE, 0 },
+
{ ngx_string("sent_http_content_type"), NULL,
ngx_http_variable_sent_content_type, 0, 0, 0 },
@@ -1456,6 +1462,39 @@
static ngx_int_t
+ngx_http_variable_status(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data)
+{
+ ngx_uint_t status;
+
+ v->data = ngx_pnalloc(r->pool, NGX_INT_T_LEN);
+ if (v->data == NULL) {
+ return NGX_ERROR;
+ }
+
+ if (r->err_status) {
+ status = r->err_status;
+
+ } else if (r->headers_out.status) {
+ status = r->headers_out.status;
+
+ } else if (r->http_version == NGX_HTTP_VERSION_9) {
+ status = 9;
+
+ } else {
+ status = 0;
+ }
+
+ v->len = ngx_sprintf(v->data, "%03ui", status) - v->data;
+ v->valid = 1;
+ v->no_cacheable = 0;
+ v->not_found = 0;
+
+ return NGX_OK;
+}
+
+
+static ngx_int_t
ngx_http_variable_sent_content_type(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data)
{
More information about the nginx-devel
mailing list