Deleted
Added
1 2/* 3 * Copyright (C) Max Romanov 4 * Copyright (C) Igor Sysoev 5 * Copyright (C) Valentin V. Bartenev 6 * Copyright (C) NGINX, Inc. 7 */ 8 --- 14 unchanged lines hidden (view full) --- 23 24static nxt_buf_t *nxt_discovery_modules(nxt_task_t *task, const char *path); 25static nxt_int_t nxt_discovery_module(nxt_task_t *task, nxt_mp_t *mp, 26 nxt_array_t *modules, const char *name); 27static nxt_app_module_t *nxt_app_module_load(nxt_task_t *task, 28 const char *name); 29static nxt_app_type_t nxt_app_parse_type(u_char *p, size_t length); 30 |
31static nxt_int_t nxt_app_request_content_length(void *ctx, 32 nxt_http_field_t *field, uintptr_t data); 33static nxt_int_t nxt_app_request_content_type(void *ctx, 34 nxt_http_field_t *field, uintptr_t data); 35static nxt_int_t nxt_app_request_cookie(void *ctx, nxt_http_field_t *field, 36 uintptr_t data); 37static nxt_int_t nxt_app_request_host(void *ctx, nxt_http_field_t *field, 38 uintptr_t data); |
39 |
40 |
41static nxt_http_field_proc_t nxt_app_request_fields[] = { 42 { nxt_string("Content-Length"), &nxt_app_request_content_length, 0 }, 43 { nxt_string("Content-Type"), &nxt_app_request_content_type, 0 }, 44 { nxt_string("Cookie"), &nxt_app_request_cookie, 0 }, 45 { nxt_string("Host"), &nxt_app_request_host, 0 }, 46}; |
47 |
48 |
49static uint32_t compat[] = { 50 NXT_VERNUM, NXT_DEBUG, 51}; 52 53 |
54static nxt_lvlhsh_t nxt_app_request_fields_hash; 55 56static nxt_thread_mutex_t nxt_app_mutex; 57static nxt_thread_cond_t nxt_app_cond; 58 59static nxt_application_module_t *nxt_app; 60 61 |
62nxt_int_t 63nxt_discovery_start(nxt_task_t *task, void *data) 64{ 65 nxt_buf_t *b; 66 nxt_port_t *main_port; 67 nxt_runtime_t *rt; 68 69 nxt_debug(task, "DISCOVERY"); --- 300 unchanged lines hidden (view full) --- 370 371 return NULL; 372} 373 374 375nxt_int_t 376nxt_app_http_init(nxt_task_t *task, nxt_runtime_t *rt) 377{ |
378 return nxt_http_fields_hash(&nxt_app_request_fields_hash, rt->mem_pool, 379 nxt_app_request_fields, 380 nxt_nitems(nxt_app_request_fields)); |
381} 382 383 384void 385nxt_port_app_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) 386{ 387 size_t dump_size; 388 nxt_buf_t *b; --- 127 unchanged lines hidden (view full) --- 516 } 517 518 return NXT_OK; 519} 520 521 522nxt_int_t 523nxt_app_msg_write_prefixed_upcase(nxt_task_t *task, nxt_app_wmsg_t *msg, |
524 const nxt_str_t *prefix, u_char *c, size_t size) |
525{ 526 u_char *dst, *src; 527 size_t i, length, dst_length; 528 |
529 length = prefix->length + size; |
530 531 dst_length = length + (length < 128 ? 1 : 4) + 1; 532 533 dst = nxt_app_msg_write_get_buf(task, msg, dst_length); 534 if (nxt_slow_path(dst == NULL)) { 535 return NXT_ERROR; 536 } 537 538 dst = nxt_app_msg_write_length(dst, length + 1); /* +1 for trailing 0 */ 539 540 nxt_memcpy(dst, prefix->start, prefix->length); 541 dst += prefix->length; 542 |
543 src = c; 544 for (i = 0; i < size; i++, dst++, src++) { |
545 546 if (*src >= 'a' && *src <= 'z') { 547 *dst = *src & ~0x20; 548 continue; 549 } 550 551 if (*src == '-') { 552 *dst = '_'; --- 155 unchanged lines hidden (view full) --- 708 nxt_debug(task, "nxt_read_size: %d", (int) *size); 709 710 return NXT_OK; 711} 712 713 714static nxt_int_t 715nxt_app_request_content_length(void *ctx, nxt_http_field_t *field, |
716 uintptr_t data) |
717{ |
718 nxt_app_parse_ctx_t *c; 719 nxt_app_request_header_t *h; 720 721 c = ctx; 722 h = &c->r.header; |
723 |
724 h->content_length.length = field->value_length; 725 h->content_length.start = field->value; |
726 |
727 h->parsed_content_length = nxt_off_t_parse(field->value, 728 field->value_length); 729 |
730 return NXT_OK; 731} 732 733 734static nxt_int_t 735nxt_app_request_content_type(void *ctx, nxt_http_field_t *field, |
736 uintptr_t data) |
737{ 738 nxt_app_parse_ctx_t *c; 739 nxt_app_request_header_t *h; 740 741 c = ctx; 742 h = &c->r.header; 743 |
744 h->content_type.length = field->value_length; 745 h->content_type.start = field->value; |
746 747 return NXT_OK; 748} 749 750 751static nxt_int_t |
752nxt_app_request_cookie(void *ctx, nxt_http_field_t *field, uintptr_t data) |
753{ 754 nxt_app_parse_ctx_t *c; 755 nxt_app_request_header_t *h; 756 757 c = ctx; 758 h = &c->r.header; 759 |
760 h->cookie.length = field->value_length; 761 h->cookie.start = field->value; |
762 763 return NXT_OK; 764} 765 766 767static nxt_int_t |
768nxt_app_request_host(void *ctx, nxt_http_field_t *field, uintptr_t data) |
769{ 770 nxt_app_parse_ctx_t *c; 771 nxt_app_request_header_t *h; 772 773 c = ctx; 774 h = &c->r.header; 775 |
776 h->host.length = field->value_length; 777 h->host.start = field->value; |
778 779 return NXT_OK; 780} 781 782 |
783nxt_app_parse_ctx_t * 784nxt_app_http_req_init(nxt_task_t *task) 785{ 786 nxt_mp_t *mp; 787 nxt_int_t rc; 788 nxt_app_parse_ctx_t *ctx; 789 790 mp = nxt_mp_create(1024, 128, 256, 32); --- 10 unchanged lines hidden (view full) --- 801 ctx->mem_pool = mp; 802 803 rc = nxt_http_parse_request_init(&ctx->parser, mp); 804 if (nxt_slow_path(rc != NXT_OK)) { 805 nxt_mp_destroy(mp); 806 return NULL; 807 } 808 |
809 return ctx; 810} 811 812 813nxt_int_t 814nxt_app_http_req_header_parse(nxt_task_t *task, nxt_app_parse_ctx_t *ctx, 815 nxt_buf_t *buf) 816{ --- 9 unchanged lines hidden (view full) --- 826 nxt_assert(h->done == 0); 827 828 rc = nxt_http_parse_request(p, &buf->mem); 829 830 if (nxt_slow_path(rc != NXT_DONE)) { 831 return rc; 832 } 833 |
834 rc = nxt_http_fields_process(p->fields, &nxt_app_request_fields_hash, ctx); |
835 836 if (nxt_slow_path(rc != NXT_OK)) { 837 return rc; 838 } 839 840 h->fields = p->fields; 841 h->done = 1; 842 --- 230 unchanged lines hidden --- |