Mercurial > hg > nginx-quic
comparison src/http/modules/ngx_http_uwsgi_module.c @ 4330:5ee5ddec17b1
uwsgi: added "if_not_empty" flag support to the "uwsgi_param" directive.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Fri, 09 Dec 2011 13:47:04 +0000 |
parents | f57229cba7ad |
children | 92deb73393f7 |
comparison
equal
deleted
inserted
replaced
4329:31e6bfca10a5 | 4330:5ee5ddec17b1 |
---|---|
303 NGX_HTTP_LOC_CONF_OFFSET, | 303 NGX_HTTP_LOC_CONF_OFFSET, |
304 offsetof(ngx_http_uwsgi_loc_conf_t, upstream.next_upstream), | 304 offsetof(ngx_http_uwsgi_loc_conf_t, upstream.next_upstream), |
305 &ngx_http_uwsgi_next_upstream_masks }, | 305 &ngx_http_uwsgi_next_upstream_masks }, |
306 | 306 |
307 { ngx_string("uwsgi_param"), | 307 { ngx_string("uwsgi_param"), |
308 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, | 308 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE23, |
309 ngx_conf_set_keyval_slot, | 309 ngx_http_upstream_param_set_slot, |
310 NGX_HTTP_LOC_CONF_OFFSET, | 310 NGX_HTTP_LOC_CONF_OFFSET, |
311 offsetof(ngx_http_uwsgi_loc_conf_t, params_source), | 311 offsetof(ngx_http_uwsgi_loc_conf_t, params_source), |
312 NULL }, | 312 NULL }, |
313 | 313 |
314 { ngx_string("uwsgi_string"), | 314 { ngx_string("uwsgi_string"), |
551 static ngx_int_t | 551 static ngx_int_t |
552 ngx_http_uwsgi_create_request(ngx_http_request_t *r) | 552 ngx_http_uwsgi_create_request(ngx_http_request_t *r) |
553 { | 553 { |
554 u_char ch, *lowcase_key; | 554 u_char ch, *lowcase_key; |
555 size_t key_len, val_len, len, allocated; | 555 size_t key_len, val_len, len, allocated; |
556 ngx_uint_t i, n, hash, header_params; | 556 ngx_uint_t i, n, hash, skip_empty, header_params; |
557 ngx_buf_t *b; | 557 ngx_buf_t *b; |
558 ngx_chain_t *cl, *body; | 558 ngx_chain_t *cl, *body; |
559 ngx_list_part_t *part; | 559 ngx_list_part_t *part; |
560 ngx_table_elt_t *header, **ignored; | 560 ngx_table_elt_t *header, **ignored; |
561 ngx_http_script_code_pt code; | 561 ngx_http_script_code_pt code; |
581 while (*(uintptr_t *) le.ip) { | 581 while (*(uintptr_t *) le.ip) { |
582 | 582 |
583 lcode = *(ngx_http_script_len_code_pt *) le.ip; | 583 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
584 key_len = lcode(&le); | 584 key_len = lcode(&le); |
585 | 585 |
586 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
587 skip_empty = lcode(&le); | |
588 | |
586 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode (&le)) { | 589 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode (&le)) { |
587 lcode = *(ngx_http_script_len_code_pt *) le.ip; | 590 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
588 } | 591 } |
589 le.ip += sizeof(uintptr_t); | 592 le.ip += sizeof(uintptr_t); |
593 | |
594 if (skip_empty && val_len == 0) { | |
595 continue; | |
596 } | |
590 | 597 |
591 len += 2 + key_len + 2 + val_len; | 598 len += 2 + key_len + 2 + val_len; |
592 } | 599 } |
593 } | 600 } |
594 | 601 |
704 while (*(uintptr_t *) le.ip) { | 711 while (*(uintptr_t *) le.ip) { |
705 | 712 |
706 lcode = *(ngx_http_script_len_code_pt *) le.ip; | 713 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
707 key_len = (u_char) lcode (&le); | 714 key_len = (u_char) lcode (&le); |
708 | 715 |
716 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
717 skip_empty = lcode(&le); | |
718 | |
709 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { | 719 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
710 lcode = *(ngx_http_script_len_code_pt *) le.ip; | 720 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
711 } | 721 } |
712 le.ip += sizeof(uintptr_t); | 722 le.ip += sizeof(uintptr_t); |
723 | |
724 if (skip_empty && val_len == 0) { | |
725 e.skip = 1; | |
726 | |
727 while (*(uintptr_t *) e.ip) { | |
728 code = *(ngx_http_script_code_pt *) e.ip; | |
729 code((ngx_http_script_engine_t *) &e); | |
730 } | |
731 e.ip += sizeof(uintptr_t); | |
732 | |
733 e.skip = 0; | |
734 | |
735 continue; | |
736 } | |
713 | 737 |
714 *e.pos++ = (u_char) (key_len & 0xff); | 738 *e.pos++ = (u_char) (key_len & 0xff); |
715 *e.pos++ = (u_char) ((key_len >> 8) & 0xff); | 739 *e.pos++ = (u_char) ((key_len >> 8) & 0xff); |
716 | 740 |
717 code = *(ngx_http_script_code_pt *) e.ip; | 741 code = *(ngx_http_script_code_pt *) e.ip; |
1377 ngx_uint_t i, nsrc; | 1401 ngx_uint_t i, nsrc; |
1378 ngx_array_t headers_names; | 1402 ngx_array_t headers_names; |
1379 #if (NGX_HTTP_CACHE) | 1403 #if (NGX_HTTP_CACHE) |
1380 ngx_array_t params_merged; | 1404 ngx_array_t params_merged; |
1381 #endif | 1405 #endif |
1382 ngx_keyval_t *src; | |
1383 ngx_hash_key_t *hk; | 1406 ngx_hash_key_t *hk; |
1384 ngx_hash_init_t hash; | 1407 ngx_hash_init_t hash; |
1408 ngx_http_upstream_param_t *src; | |
1385 ngx_http_script_compile_t sc; | 1409 ngx_http_script_compile_t sc; |
1386 ngx_http_script_copy_code_t *copy; | 1410 ngx_http_script_copy_code_t *copy; |
1387 | 1411 |
1388 if (conf->params_source == NULL) { | 1412 if (conf->params_source == NULL) { |
1389 conf->params_source = prev->params_source; | 1413 conf->params_source = prev->params_source; |
1440 } | 1464 } |
1441 | 1465 |
1442 #if (NGX_HTTP_CACHE) | 1466 #if (NGX_HTTP_CACHE) |
1443 | 1467 |
1444 if (conf->upstream.cache) { | 1468 if (conf->upstream.cache) { |
1445 ngx_keyval_t *h, *s; | 1469 ngx_keyval_t *h; |
1446 | 1470 ngx_http_upstream_param_t *s; |
1447 if (ngx_array_init(¶ms_merged, cf->temp_pool, 4, sizeof(ngx_keyval_t)) | 1471 |
1472 if (ngx_array_init(¶ms_merged, cf->temp_pool, 4, | |
1473 sizeof(ngx_http_upstream_param_t)) | |
1448 != NGX_OK) | 1474 != NGX_OK) |
1449 { | 1475 { |
1450 return NGX_ERROR; | 1476 return NGX_ERROR; |
1451 } | 1477 } |
1452 | 1478 |
1476 s = ngx_array_push(¶ms_merged); | 1502 s = ngx_array_push(¶ms_merged); |
1477 if (s == NULL) { | 1503 if (s == NULL) { |
1478 return NGX_ERROR; | 1504 return NGX_ERROR; |
1479 } | 1505 } |
1480 | 1506 |
1481 *s = *h; | 1507 s->key = h->key; |
1508 s->value = h->value; | |
1509 s->skip_empty = 0; | |
1482 | 1510 |
1483 next: | 1511 next: |
1484 | 1512 |
1485 h++; | 1513 h++; |
1486 } | 1514 } |
1517 return NGX_ERROR; | 1545 return NGX_ERROR; |
1518 } | 1546 } |
1519 | 1547 |
1520 copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; | 1548 copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; |
1521 copy->len = src[i].key.len; | 1549 copy->len = src[i].key.len; |
1550 | |
1551 copy = ngx_array_push_n(conf->params_len, | |
1552 sizeof(ngx_http_script_copy_code_t)); | |
1553 if (copy == NULL) { | |
1554 return NGX_ERROR; | |
1555 } | |
1556 | |
1557 copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; | |
1558 copy->len = src[i].skip_empty; | |
1522 | 1559 |
1523 | 1560 |
1524 size = (sizeof(ngx_http_script_copy_code_t) | 1561 size = (sizeof(ngx_http_script_copy_code_t) |
1525 + src[i].key.len + sizeof(uintptr_t) - 1) | 1562 + src[i].key.len + sizeof(uintptr_t) - 1) |
1526 & ~(sizeof(uintptr_t) - 1); | 1563 & ~(sizeof(uintptr_t) - 1); |