Mercurial > hg > nginx
comparison src/http/modules/perl/nginx.xs @ 667:63a820b0bc6c release-0.3.55
nginx-0.3.55-RELEASE import
*) Feature: the "stub" parameter in the "include" SSI command.
*) Feature: the "block" SSI command.
*) Feature: the unicode2nginx script was added to contrib.
*) Bugfix: if a "root" was specified by variable only, then the root
was relative to a server prefix.
*) Bugfix: if the request contained "//" or "/./" and escaped symbols
after them, then the proxied request was sent unescaped.
*) Bugfix: the $r->headers_in("Cookie") of the ngx_http_perl_module now
returns all "Cookie" header lines.
*) Bugfix: a segmentation fault occurred if
"client_body_in_file_only on" was used and nginx switched to a next
upstream.
*) Bugfix: on some condition while reconfiguration character codes
inside the "charset_map" may be treated invalid; the bug had
appeared in 0.3.50.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 28 Jul 2006 15:16:17 +0000 |
parents | f971949ffb58 |
children | b80f94fa2197 |
comparison
equal
deleted
inserted
replaced
666:ddaa33b0817a | 667:63a820b0bc6c |
---|---|
197 void | 197 void |
198 header_in(r, key) | 198 header_in(r, key) |
199 CODE: | 199 CODE: |
200 | 200 |
201 dXSTARG; | 201 dXSTARG; |
202 ngx_http_request_t *r; | 202 ngx_http_request_t *r; |
203 SV *key; | 203 SV *key; |
204 u_char *p; | 204 u_char *p, *lowcase_key, *cookie; |
205 STRLEN len; | 205 STRLEN len; |
206 ngx_uint_t i; | 206 ssize_t size; |
207 ngx_list_part_t *part; | 207 ngx_uint_t i, n, hash; |
208 ngx_table_elt_t *header; | 208 ngx_list_part_t *part; |
209 ngx_table_elt_t *h, **ph; | |
210 ngx_http_header_t *hh; | |
211 ngx_http_core_main_conf_t *cmcf; | |
209 | 212 |
210 ngx_http_perl_set_request(r); | 213 ngx_http_perl_set_request(r); |
211 | 214 |
212 key = ST(1); | 215 key = ST(1); |
213 | 216 |
215 key = SvRV(key); | 218 key = SvRV(key); |
216 } | 219 } |
217 | 220 |
218 p = (u_char *) SvPV(key, len); | 221 p = (u_char *) SvPV(key, len); |
219 | 222 |
223 /* look up hashed headers */ | |
224 | |
225 lowcase_key = ngx_palloc(r->pool, len); | |
226 if (lowcase_key == NULL) { | |
227 XSRETURN_UNDEF; | |
228 } | |
229 | |
230 hash = 0; | |
231 for (i = 0; i < len; i++) { | |
232 lowcase_key[i] = ngx_tolower(p[i]); | |
233 hash = ngx_hash(hash, lowcase_key[i]); | |
234 } | |
235 | |
236 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); | |
237 | |
238 hh = ngx_hash_find(&cmcf->headers_in_hash, hash, lowcase_key, len); | |
239 | |
240 if (hh) { | |
241 if (hh->offset) { | |
242 | |
243 ph = (ngx_table_elt_t **) ((char *) &r->headers_in + hh->offset); | |
244 | |
245 if (*ph) { | |
246 ngx_http_perl_set_targ((*ph)->value.data, (*ph)->value.len, 0); | |
247 | |
248 goto done; | |
249 } | |
250 | |
251 XSRETURN_UNDEF; | |
252 } | |
253 | |
254 /* Cookie */ | |
255 | |
256 n = r->headers_in.cookies.nelts; | |
257 | |
258 if (n == 0) { | |
259 XSRETURN_UNDEF; | |
260 } | |
261 | |
262 ph = r->headers_in.cookies.elts; | |
263 | |
264 if (n == 1) { | |
265 ngx_http_perl_set_targ((*ph)->value.data, (*ph)->value.len, 0); | |
266 | |
267 goto done; | |
268 } | |
269 | |
270 size = - (ssize_t) (sizeof("; ") - 1); | |
271 | |
272 for (i = 0; i < n; i++) { | |
273 size += ph[i]->value.len + sizeof("; ") - 1; | |
274 } | |
275 | |
276 cookie = ngx_palloc(r->pool, size); | |
277 if (cookie == NULL) { | |
278 XSRETURN_UNDEF; | |
279 } | |
280 | |
281 p = cookie; | |
282 | |
283 for (i = 0; /* void */ ; i++) { | |
284 p = ngx_copy(p, ph[i]->value.data, ph[i]->value.len); | |
285 | |
286 if (i == n - 1) { | |
287 break; | |
288 } | |
289 | |
290 *p++ = ';'; *p++ = ' '; | |
291 } | |
292 | |
293 ngx_http_perl_set_targ(cookie, size, 0); | |
294 | |
295 goto done; | |
296 } | |
297 | |
298 /* iterate over all headers */ | |
299 | |
220 part = &r->headers_in.headers.part; | 300 part = &r->headers_in.headers.part; |
221 header = part->elts; | 301 h = part->elts; |
222 | 302 |
223 for (i = 0; /* void */ ; i++) { | 303 for (i = 0; /* void */ ; i++) { |
224 | 304 |
225 if (i >= part->nelts) { | 305 if (i >= part->nelts) { |
226 if (part->next == NULL) { | 306 if (part->next == NULL) { |
227 break; | 307 break; |
228 } | 308 } |
229 | 309 |
230 part = part->next; | 310 part = part->next; |
231 header = part->elts; | 311 h = part->elts; |
232 i = 0; | 312 i = 0; |
233 } | 313 } |
234 | 314 |
235 if (len != header[i].key.len | 315 if (len != h[i].key.len |
236 || ngx_strcasecmp(p, header[i].key.data) != 0) | 316 || ngx_strcasecmp(p, h[i].key.data) != 0) |
237 { | 317 { |
238 continue; | 318 continue; |
239 } | 319 } |
240 | 320 |
241 ngx_http_perl_set_targ(header[i].value.data, header[i].value.len, 0); | 321 ngx_http_perl_set_targ(h[i].value.data, h[i].value.len, 0); |
242 | 322 |
243 goto done; | 323 goto done; |
244 } | 324 } |
245 | 325 |
246 XSRETURN_UNDEF; | 326 XSRETURN_UNDEF; |