Mercurial > hg > nginx-vendor-0-7
annotate src/http/modules/ngx_http_stub_status_module.c @ 58:b55cbf18157e NGINX_0_1_29
nginx 0.1.29
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; bug appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Thu, 12 May 2005 00:00:00 +0400 |
parents | 72eb30262aac |
children | 71c46860eb55 |
rev | line source |
---|---|
36 | 1 |
2 #include <ngx_config.h> | |
3 #include <ngx_core.h> | |
4 #include <ngx_http.h> | |
5 | |
6 | |
7 static char *ngx_http_set_status(ngx_conf_t *cf, ngx_command_t *cmd, | |
8 void *conf); | |
9 | |
10 static ngx_command_t ngx_http_status_commands[] = { | |
11 | |
12 { ngx_string("stub_status"), | |
13 NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
14 ngx_http_set_status, | |
15 0, | |
16 0, | |
17 NULL }, | |
18 | |
19 ngx_null_command | |
20 }; | |
21 | |
22 | |
23 | |
24 ngx_http_module_t ngx_http_stub_status_module_ctx = { | |
58 | 25 NULL, /* preconfiguration */ |
26 NULL, /* postconfiguration */ | |
36 | 27 |
28 NULL, /* create main configuration */ | |
29 NULL, /* init main configuration */ | |
30 | |
31 NULL, /* create server configuration */ | |
32 NULL, /* merge server configuration */ | |
33 | |
34 NULL, /* create location configuration */ | |
35 NULL /* merge location configuration */ | |
36 }; | |
37 | |
38 | |
39 ngx_module_t ngx_http_stub_status_module = { | |
58 | 40 NGX_MODULE_V1, |
36 | 41 &ngx_http_stub_status_module_ctx, /* module context */ |
42 ngx_http_status_commands, /* module directives */ | |
43 NGX_HTTP_MODULE, /* module type */ | |
44 NULL, /* init module */ | |
45 NULL /* init process */ | |
46 }; | |
47 | |
48 | |
49 static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r) | |
50 { | |
44 | 51 size_t size; |
52 ngx_int_t rc; | |
53 ngx_buf_t *b; | |
54 ngx_chain_t out; | |
55 ngx_atomic_int_t ap, hn, ac, rq, rd, wr; | |
36 | 56 |
57 if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) { | |
58 return NGX_HTTP_NOT_ALLOWED; | |
59 } | |
60 | |
61 rc = ngx_http_discard_body(r); | |
62 | |
63 if (rc != NGX_OK && rc != NGX_AGAIN) { | |
64 return rc; | |
65 } | |
66 | |
58 | 67 r->headers_out.content_type.len = sizeof("text/plain") - 1; |
68 r->headers_out.content_type.data = (u_char *) "text/plain"; | |
36 | 69 |
70 if (r->method == NGX_HTTP_HEAD) { | |
71 r->headers_out.status = NGX_HTTP_OK; | |
72 | |
73 rc = ngx_http_send_header(r); | |
74 | |
75 if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) { | |
76 return rc; | |
77 } | |
78 } | |
79 | |
44 | 80 size = sizeof("Active connections: \n") + NGX_ATOMIC_T_LEN |
36 | 81 + sizeof("server accepts handled requests\n") - 1 |
44 | 82 + 6 + 3 * NGX_ATOMIC_T_LEN |
83 + sizeof("Reading: Writing: Waiting: \n") + 3 * NGX_ATOMIC_T_LEN; | |
36 | 84 |
50 | 85 b = ngx_create_temp_buf(r->pool, size); |
86 if (b == NULL) { | |
36 | 87 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
88 } | |
89 | |
90 out.buf = b; | |
91 out.next = NULL; | |
92 | |
93 ap = *ngx_stat_accepted; | |
44 | 94 hn = *ngx_stat_handled; |
36 | 95 ac = *ngx_stat_active; |
96 rq = *ngx_stat_requests; | |
97 rd = *ngx_stat_reading; | |
98 wr = *ngx_stat_writing; | |
99 | |
58 | 100 b->last = ngx_sprintf(b->last, "Active connections: %uA \n", ac); |
36 | 101 |
102 b->last = ngx_cpymem(b->last, "server accepts handled requests\n", | |
103 sizeof("server accepts handled requests\n") - 1); | |
104 | |
58 | 105 b->last = ngx_sprintf(b->last, " %uA %uA %uA \n", ap, hn, rq); |
36 | 106 |
58 | 107 b->last = ngx_sprintf(b->last, "Reading: %uA Writing: %uA Waiting: %uA \n", |
42 | 108 rd, wr, ac - (rd + wr)); |
36 | 109 |
110 r->headers_out.status = NGX_HTTP_OK; | |
111 r->headers_out.content_length_n = b->last - b->pos; | |
112 | |
113 b->last_buf = 1; | |
114 | |
115 rc = ngx_http_send_header(r); | |
116 | |
117 if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) { | |
118 return rc; | |
119 } | |
120 | |
121 return ngx_http_output_filter(r, &out);; | |
122 } | |
123 | |
124 | |
125 static char *ngx_http_set_status(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
126 { | |
127 ngx_http_core_loc_conf_t *clcf; | |
128 | |
129 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); | |
130 clcf->handler = ngx_http_status_handler; | |
131 | |
132 return NGX_CONF_OK; | |
133 } |