Mercurial > hg > nginx
comparison src/http/modules/ngx_http_status_handler.c @ 368:15c84a40e87d
nginx-0.0.7-2004-06-24-20:07:04 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 24 Jun 2004 16:07:04 +0000 |
parents | ceec87d1c2b3 |
children | 9c2515d70489 |
comparison
equal
deleted
inserted
replaced
367:ceec87d1c2b3 | 368:15c84a40e87d |
---|---|
44 }; | 44 }; |
45 | 45 |
46 | 46 |
47 static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r) | 47 static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r) |
48 { | 48 { |
49 u_char ch; | |
49 size_t len; | 50 size_t len; |
50 ngx_int_t rc; | 51 ngx_int_t rc; |
51 ngx_uint_t i, dash; | 52 ngx_uint_t i, dash; |
52 ngx_buf_t *b; | 53 ngx_buf_t *b; |
53 ngx_chain_t out; | 54 ngx_chain_t out; |
91 c = ngx_cycle->connections; | 92 c = ngx_cycle->connections; |
92 for (i = 0; i < ngx_cycle->connection_n; i++) { | 93 for (i = 0; i < ngx_cycle->connection_n; i++) { |
93 rq = c[i].data; | 94 rq = c[i].data; |
94 if (rq && rq->signature == NGX_HTTP_MODULE) { | 95 if (rq && rq->signature == NGX_HTTP_MODULE) { |
95 | 96 |
97 /* STUB: should be NGX_PID_T_LEN */ | |
98 len += NGX_INT64_LEN /* pid */ | |
99 + 1 + NGX_INT32_LEN /* connection */ | |
100 + 1 + 1 /* state */ | |
101 + 1 + c[i].addr_text.len | |
102 + 1 + rq->server_name->len | |
103 + 2; /* "\r\n" */ | |
104 | |
96 if (rq->request_line.len) { | 105 if (rq->request_line.len) { |
97 len += NGX_INT32_LEN + 1 + rq->request_line.len + 2 + 2; | 106 len += 1 + rq->request_line.len + 2; |
98 dash = 0; | |
99 } | 107 } |
108 | |
109 dash = 0; | |
100 | 110 |
101 continue; | 111 continue; |
102 } | 112 } |
103 | 113 |
104 if (!dash) { | 114 if (!dash) { |
115 | 125 |
116 for (i = 0; i < ngx_cycle->connection_n; i++) { | 126 for (i = 0; i < ngx_cycle->connection_n; i++) { |
117 rq = c[i].data; | 127 rq = c[i].data; |
118 if (rq && rq->signature == NGX_HTTP_MODULE) { | 128 if (rq && rq->signature == NGX_HTTP_MODULE) { |
119 | 129 |
120 #if 0 | 130 b->last += ngx_snprintf((char *) b->last, |
131 /* STUB: should be NGX_PID_T_LEN */ | |
132 NGX_INT64_LEN + NGX_INT32_LEN, | |
133 PID_T_FMT " %u", ngx_pid, i); | |
134 | |
121 switch (rq->http_state) { | 135 switch (rq->http_state) { |
122 case NGX_HTTP_INITING_REQUEST_STATE: | 136 case NGX_HTTP_INITING_REQUEST_STATE: |
137 ch = 'I'; | |
138 break; | |
139 | |
140 case NGX_HTTP_READING_REQUEST_STATE: | |
141 ch = 'R'; | |
142 break; | |
143 | |
144 case NGX_HTTP_PROCESS_REQUEST_STATE: | |
145 ch = 'P'; | |
146 break; | |
147 | |
148 case NGX_HTTP_WRITING_REQUEST_STATE: | |
149 ch = 'W'; | |
150 break; | |
123 | 151 |
124 case NGX_HTTP_KEEPALIVE_STATE: | 152 case NGX_HTTP_KEEPALIVE_STATE: |
153 ch = 'K'; | |
154 break; | |
155 | |
156 default: | |
157 ch = '?'; | |
125 } | 158 } |
126 #endif | 159 |
160 *(b->last++) = ' '; | |
161 *(b->last++) = ch; | |
162 | |
163 *(b->last++) = ' '; | |
164 b->last = ngx_cpymem(b->last, c[i].addr_text.data, | |
165 c[i].addr_text.len); | |
166 | |
167 *(b->last++) = ' '; | |
168 b->last = ngx_cpymem(b->last, rq->server_name->data, | |
169 rq->server_name->len); | |
127 | 170 |
128 if (rq->request_line.len) { | 171 if (rq->request_line.len) { |
129 b->last += ngx_snprintf((char *) b->last, NGX_INT32_LEN, | |
130 "%u", i); | |
131 *(b->last++) = ' '; | 172 *(b->last++) = ' '; |
132 | |
133 *(b->last++) = '"'; | 173 *(b->last++) = '"'; |
134 b->last = ngx_cpymem(b->last, r->request_line.data, | 174 b->last = ngx_cpymem(b->last, r->request_line.data, |
135 r->request_line.len); | 175 r->request_line.len); |
136 *(b->last++) = '"'; | 176 *(b->last++) = '"'; |
137 | 177 |
138 *(b->last++) = CR; *(b->last++) = LF; | |
139 dash = 0; | |
140 } | 178 } |
179 | |
180 *(b->last++) = CR; *(b->last++) = LF; | |
181 | |
182 dash = 0; | |
141 | 183 |
142 continue; | 184 continue; |
143 } | 185 } |
144 | 186 |
145 if (!dash) { | 187 if (!dash) { |