Mercurial > hg > nginx
comparison src/http/modules/proxy/ngx_http_proxy_handler.c @ 195:8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 25 Nov 2003 20:44:56 +0000 |
parents | dd66383796a5 |
children | 0b67be7d4489 |
comparison
equal
deleted
inserted
replaced
194:2357fa41738a | 195:8dee38ea9117 |
---|---|
483 | 483 |
484 } else if (p->cache) { | 484 } else if (p->cache) { |
485 r->file.fd = p->cache->ctx.file.fd; | 485 r->file.fd = p->cache->ctx.file.fd; |
486 } | 486 } |
487 | 487 |
488 if (rc == 0 && r->main == NULL) { | |
489 rc = ngx_http_send_last(r); | |
490 } | |
491 | |
488 ngx_http_finalize_request(r, rc); | 492 ngx_http_finalize_request(r, rc); |
489 } | 493 } |
490 | 494 |
491 | 495 |
492 void ngx_http_proxy_close_connection(ngx_http_proxy_ctx_t *p) | 496 void ngx_http_proxy_close_connection(ngx_http_proxy_ctx_t *p) |
584 cache_states[p->state->cache_state - 1].len); | 588 cache_states[p->state->cache_state - 1].len); |
585 } | 589 } |
586 | 590 |
587 *buf++ = '/'; | 591 *buf++ = '/'; |
588 | 592 |
589 *buf++ = '_'; | 593 if (p->state->expired == 0) { |
594 *buf++ = '-'; | |
595 | |
596 } else { | |
597 buf += ngx_snprintf(buf, NGX_TIME_LEN, TIME_T_FMT, p->state->expired); | |
598 } | |
590 | 599 |
591 *buf++ = '/'; | 600 *buf++ = '/'; |
592 | 601 |
593 *buf++ = '_'; | 602 if (p->state->bl_time == 0) { |
603 *buf++ = '-'; | |
604 | |
605 } else { | |
606 buf += ngx_snprintf(buf, NGX_TIME_LEN, TIME_T_FMT, p->state->bl_time); | |
607 } | |
594 | 608 |
595 *buf++ = '/'; | 609 *buf++ = '/'; |
596 | 610 |
597 *buf++ = '_'; | 611 *buf++ = '*'; |
598 | 612 |
599 *buf++ = ' '; | 613 *buf++ = ' '; |
600 | 614 |
601 if (p->state->status == 0) { | 615 if (p->state->status == 0) { |
602 *buf++ = '-'; | 616 *buf++ = '-'; |
615 cache_reasons[p->state->reason - 1].len); | 629 cache_reasons[p->state->reason - 1].len); |
616 } | 630 } |
617 | 631 |
618 *buf++ = '/'; | 632 *buf++ = '/'; |
619 | 633 |
620 if (p->state->reason >= NGX_HTTP_PROXY_CACHE_XAE) { | 634 if (p->state->reason < NGX_HTTP_PROXY_CACHE_XAE) { |
621 *buf++ = '-'; | 635 *buf++ = '-'; |
622 | 636 |
623 } else { | 637 } else { |
624 buf += ngx_snprintf(buf, NGX_TIME_LEN, TIME_FMT, p->state->expires); | 638 buf += ngx_snprintf(buf, NGX_TIME_LEN, TIME_T_FMT, p->state->expires); |
625 } | 639 } |
626 | 640 |
627 *buf++ = ' '; | 641 *buf++ = ' '; |
628 *buf++ = '_'; | 642 *buf++ = '*'; |
629 | 643 |
630 return buf; | 644 return buf; |
631 } | 645 } |
632 | 646 |
633 | 647 |
831 { | 845 { |
832 ngx_http_proxy_loc_conf_t *lcf = conf; | 846 ngx_http_proxy_loc_conf_t *lcf = conf; |
833 | 847 |
834 int i, len; | 848 int i, len; |
835 char *err, *host; | 849 char *err, *host; |
850 in_addr_t addr; | |
836 ngx_str_t *value; | 851 ngx_str_t *value; |
837 struct hostent *h; | 852 struct hostent *h; |
838 u_int32_t addr; | |
839 ngx_http_conf_ctx_t *ctx; | 853 ngx_http_conf_ctx_t *ctx; |
840 ngx_http_core_loc_conf_t *clcf; | 854 ngx_http_core_loc_conf_t *clcf; |
841 | 855 |
842 | 856 |
843 value = cf->args->elts; | 857 value = cf->args->elts; |
866 } | 880 } |
867 | 881 |
868 ngx_test_null(host, ngx_palloc(cf->pool, lcf->upstream->host.len + 1), | 882 ngx_test_null(host, ngx_palloc(cf->pool, lcf->upstream->host.len + 1), |
869 NGX_CONF_ERROR); | 883 NGX_CONF_ERROR); |
870 ngx_cpystrn(host, lcf->upstream->host.data, lcf->upstream->host.len + 1); | 884 ngx_cpystrn(host, lcf->upstream->host.data, lcf->upstream->host.len + 1); |
885 | |
886 /* AF_INET only */ | |
871 | 887 |
872 addr = inet_addr(host); | 888 addr = inet_addr(host); |
873 | 889 |
874 if (addr == INADDR_NONE) { | 890 if (addr == INADDR_NONE) { |
875 h = gethostbyname(host); | 891 h = gethostbyname(host); |
892 lcf->peers->number = i; | 908 lcf->peers->number = i; |
893 | 909 |
894 for (i = 0; h->h_addr_list[i] != NULL; i++) { | 910 for (i = 0; h->h_addr_list[i] != NULL; i++) { |
895 lcf->peers->peers[i].host.data = host; | 911 lcf->peers->peers[i].host.data = host; |
896 lcf->peers->peers[i].host.len = lcf->upstream->host.len; | 912 lcf->peers->peers[i].host.len = lcf->upstream->host.len; |
897 lcf->peers->peers[i].addr = *(u_int32_t *)(h->h_addr_list[i]); | 913 lcf->peers->peers[i].addr = *(in_addr_t *)(h->h_addr_list[i]); |
898 lcf->peers->peers[i].port = lcf->upstream->port; | 914 lcf->peers->peers[i].port = lcf->upstream->port; |
899 | 915 |
900 len = INET_ADDRSTRLEN + lcf->upstream->port_text.len + 1; | 916 len = INET_ADDRSTRLEN + lcf->upstream->port_text.len + 1; |
901 ngx_test_null(lcf->peers->peers[i].addr_port_text.data, | 917 ngx_test_null(lcf->peers->peers[i].addr_port_text.data, |
902 ngx_palloc(cf->pool, len), | 918 ngx_palloc(cf->pool, len), |