Mercurial > hg > nginx-ranges
comparison src/http/modules/proxy/ngx_http_proxy_handler.c @ 10:46833bd150cb NGINX_0_1_5
nginx 0.1.5
*) Bugfix: on Solaris and Linux there may be too many "recvmsg()
returned not enough data" alerts.
*) Bugfix: there were the "writev() failed (22: Invalid argument)"
errors on Solaris in proxy mode without sendfile. On other platforms
that do not support sendfile at all the process got caught in an
endless loop.
*) Bugfix: segmentation fault on Solaris in proxy mode and using
sendfile.
*) Bugfix: segmentation fault on Solaris.
*) Bugfix: on-line upgrade did not work on Linux.
*) Bugfix: the ngx_http_autoindex_module module did not escape the
spaces, the quotes, and the percent signs in the directory listing.
*) Change: the decrease of the copy operations.
*) Feature: the userid_p3p directive.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Thu, 11 Nov 2004 00:00:00 +0300 |
parents | 80ba094c6b3e |
children | 74b1868dd3cd |
comparison
equal
deleted
inserted
replaced
9:77eee314ddbd | 10:46833bd150cb |
---|---|
708 ngx_close_socket_n " failed"); | 708 ngx_close_socket_n " failed"); |
709 } | 709 } |
710 } | 710 } |
711 | 711 |
712 | 712 |
713 size_t ngx_http_proxy_log_error(void *data, char *buf, size_t len) | 713 u_char *ngx_http_proxy_log_error(void *data, u_char *buf, size_t len) |
714 { | 714 { |
715 ngx_http_proxy_log_ctx_t *ctx = data; | 715 ngx_http_proxy_log_ctx_t *ctx = data; |
716 | 716 |
717 ngx_http_request_t *r; | 717 u_char *p; |
718 ngx_peer_connection_t *peer; | 718 ngx_int_t escape; |
719 ngx_str_t uri; | |
720 ngx_http_request_t *r; | |
721 ngx_peer_connection_t *peer; | |
722 ngx_http_proxy_upstream_conf_t *uc; | |
719 | 723 |
720 r = ctx->proxy->request; | 724 r = ctx->proxy->request; |
725 uc = ctx->proxy->lcf->upstream; | |
721 peer = &ctx->proxy->upstream->peer; | 726 peer = &ctx->proxy->upstream->peer; |
722 | 727 |
723 return ngx_snprintf(buf, len, | 728 p = ngx_snprintf(buf, len, |
724 " while %s, client: %s, URL: %s, upstream: %s%s%s%s%s", | 729 " while %s, client: %V, URL: %V, upstream: %V%V", |
725 ctx->proxy->action, | 730 ctx->proxy->action, |
726 r->connection->addr_text.data, | 731 &r->connection->addr_text, |
727 r->unparsed_uri.data, | 732 &r->unparsed_uri, |
728 peer->peers->peers[peer->cur_peer].addr_port_text.data, | 733 &peer->peers->peers[peer->cur_peer].addr_port_text, |
729 ctx->proxy->lcf->upstream->uri.data, | 734 &ctx->proxy->lcf->upstream->uri); |
730 r->uri.data + ctx->proxy->lcf->upstream->location->len, | 735 len -= p - buf; |
731 r->args.len ? "?" : "", | 736 buf = p; |
732 r->args.len ? r->args.data : (u_char *) ""); | 737 |
738 if (r->quoted_uri) { | |
739 escape = 2 * ngx_escape_uri(NULL, r->uri.data + uc->location->len, | |
740 r->uri.len - uc->location->len, | |
741 NGX_ESCAPE_URI); | |
742 } else { | |
743 escape = 0; | |
744 } | |
745 | |
746 if (escape) { | |
747 if (len >= r->uri.len - uc->location->len + escape) { | |
748 | |
749 ngx_escape_uri(buf, r->uri.data + uc->location->len, | |
750 r->uri.len - uc->location->len, NGX_ESCAPE_URI); | |
751 | |
752 buf += r->uri.len - uc->location->len + escape; | |
753 | |
754 if (r->args.len == 0) { | |
755 return buf; | |
756 } | |
757 | |
758 len -= r->uri.len - uc->location->len + escape; | |
759 | |
760 return ngx_snprintf(buf, len, "?%V", &r->args); | |
761 } | |
762 | |
763 p = ngx_palloc(r->pool, r->uri.len - uc->location->len + escape); | |
764 if (p == NULL) { | |
765 return buf; | |
766 } | |
767 | |
768 ngx_escape_uri(p, r->uri.data + uc->location->len, | |
769 r->uri.len - uc->location->len, NGX_ESCAPE_URI); | |
770 | |
771 uri.len = r->uri.len - uc->location->len + escape; | |
772 uri.data = p; | |
773 | |
774 } else { | |
775 uri.len = r->uri.len - uc->location->len; | |
776 uri.data = r->uri.data + uc->location->len; | |
777 | |
778 } | |
779 | |
780 return ngx_snprintf(buf, len, "%V%s%V", | |
781 &uri, r->args.len ? "?" : "", &r->args); | |
733 } | 782 } |
734 | 783 |
735 | 784 |
736 static u_char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r, | 785 static u_char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r, |
737 u_char *buf, uintptr_t data) | 786 u_char *buf, uintptr_t data) |
757 | 806 |
758 if (p->state->expired == 0) { | 807 if (p->state->expired == 0) { |
759 *buf++ = '-'; | 808 *buf++ = '-'; |
760 | 809 |
761 } else { | 810 } else { |
762 buf += ngx_snprintf((char *) buf, TIME_T_LEN, | 811 buf = ngx_sprintf(buf, "%T", p->state->expired); |
763 TIME_T_FMT, p->state->expired); | |
764 } | 812 } |
765 | 813 |
766 *buf++ = '/'; | 814 *buf++ = '/'; |
767 | 815 |
768 if (p->state->bl_time == 0) { | 816 if (p->state->bl_time == 0) { |
769 *buf++ = '-'; | 817 *buf++ = '-'; |
770 | 818 |
771 } else { | 819 } else { |
772 buf += ngx_snprintf((char *) buf, TIME_T_LEN, | 820 buf = ngx_sprintf(buf, "%T", p->state->bl_time); |
773 TIME_T_FMT, p->state->bl_time); | |
774 } | 821 } |
775 | 822 |
776 *buf++ = '/'; | 823 *buf++ = '/'; |
777 | 824 |
778 *buf++ = '*'; | 825 *buf++ = '*'; |
781 | 828 |
782 if (p->state->status == 0) { | 829 if (p->state->status == 0) { |
783 *buf++ = '-'; | 830 *buf++ = '-'; |
784 | 831 |
785 } else { | 832 } else { |
786 buf += ngx_snprintf((char *) buf, 4, "%" NGX_UINT_T_FMT, | 833 buf = ngx_sprintf(buf, "%ui", p->state->status); |
787 p->state->status); | |
788 } | 834 } |
789 | 835 |
790 *buf++ = '/'; | 836 *buf++ = '/'; |
791 | 837 |
792 if (p->state->reason == 0) { | 838 if (p->state->reason == 0) { |
801 | 847 |
802 if (p->state->reason < NGX_HTTP_PROXY_CACHE_XAE) { | 848 if (p->state->reason < NGX_HTTP_PROXY_CACHE_XAE) { |
803 *buf++ = '-'; | 849 *buf++ = '-'; |
804 | 850 |
805 } else { | 851 } else { |
806 buf += ngx_snprintf((char *) buf, TIME_T_LEN, | 852 buf = ngx_sprintf(buf, "%T", p->state->expires); |
807 TIME_T_FMT, p->state->expires); | |
808 } | 853 } |
809 | 854 |
810 *buf++ = ' '; | 855 *buf++ = ' '; |
811 *buf++ = '*'; | 856 *buf++ = '*'; |
812 | 857 |
1164 lcf->peers->peers[i].host.data = host; | 1209 lcf->peers->peers[i].host.data = host; |
1165 lcf->peers->peers[i].host.len = lcf->upstream->host.len; | 1210 lcf->peers->peers[i].host.len = lcf->upstream->host.len; |
1166 lcf->peers->peers[i].addr = *(in_addr_t *)(h->h_addr_list[i]); | 1211 lcf->peers->peers[i].addr = *(in_addr_t *)(h->h_addr_list[i]); |
1167 lcf->peers->peers[i].port = lcf->upstream->port; | 1212 lcf->peers->peers[i].port = lcf->upstream->port; |
1168 | 1213 |
1169 len = INET_ADDRSTRLEN + lcf->upstream->port_text.len + 1; | 1214 len = INET_ADDRSTRLEN - 1 + 1 + lcf->upstream->port_text.len; |
1170 | 1215 |
1171 lcf->peers->peers[i].addr_port_text.data = | 1216 lcf->peers->peers[i].addr_port_text.data = |
1172 ngx_palloc(cf->pool, len); | 1217 ngx_palloc(cf->pool, len); |
1173 if (lcf->peers->peers[i].addr_port_text.data == NULL) { | 1218 if (lcf->peers->peers[i].addr_port_text.data == NULL) { |
1174 return NGX_CONF_ERROR; | 1219 return NGX_CONF_ERROR; |
1179 lcf->peers->peers[i].addr_port_text.data, | 1224 lcf->peers->peers[i].addr_port_text.data, |
1180 len); | 1225 len); |
1181 | 1226 |
1182 lcf->peers->peers[i].addr_port_text.data[len++] = ':'; | 1227 lcf->peers->peers[i].addr_port_text.data[len++] = ':'; |
1183 | 1228 |
1184 ngx_cpystrn(lcf->peers->peers[i].addr_port_text.data + len, | 1229 ngx_memcpy(lcf->peers->peers[i].addr_port_text.data + len, |
1185 lcf->upstream->port_text.data, | 1230 lcf->upstream->port_text.data, |
1186 lcf->upstream->port_text.len + 1); | 1231 lcf->upstream->port_text.len); |
1187 | 1232 |
1188 lcf->peers->peers[i].addr_port_text.len = | 1233 lcf->peers->peers[i].addr_port_text.len = |
1189 len + lcf->upstream->port_text.len + 1; | 1234 len + lcf->upstream->port_text.len; |
1190 } | 1235 } |
1191 | 1236 |
1192 } else { | 1237 } else { |
1193 | 1238 |
1194 /* MP: ngx_shared_palloc() */ | 1239 /* MP: ngx_shared_palloc() */ |
1202 lcf->peers->peers[0].host.data = host; | 1247 lcf->peers->peers[0].host.data = host; |
1203 lcf->peers->peers[0].host.len = lcf->upstream->host.len; | 1248 lcf->peers->peers[0].host.len = lcf->upstream->host.len; |
1204 lcf->peers->peers[0].addr = addr; | 1249 lcf->peers->peers[0].addr = addr; |
1205 lcf->peers->peers[0].port = lcf->upstream->port; | 1250 lcf->peers->peers[0].port = lcf->upstream->port; |
1206 | 1251 |
1207 len = lcf->upstream->host.len + lcf->upstream->port_text.len + 1; | 1252 len = lcf->upstream->host.len + 1 + lcf->upstream->port_text.len; |
1208 | 1253 |
1209 lcf->peers->peers[0].addr_port_text.data = | 1254 lcf->peers->peers[0].addr_port_text.len = len; |
1210 ngx_palloc(cf->pool, len + 1); | 1255 |
1256 lcf->peers->peers[0].addr_port_text.data = ngx_palloc(cf->pool, len); | |
1211 if (lcf->peers->peers[0].addr_port_text.data == NULL) { | 1257 if (lcf->peers->peers[0].addr_port_text.data == NULL) { |
1212 return NGX_CONF_ERROR; | 1258 return NGX_CONF_ERROR; |
1213 } | 1259 } |
1214 | 1260 |
1215 len = lcf->upstream->host.len; | 1261 len = lcf->upstream->host.len; |
1217 ngx_memcpy(lcf->peers->peers[0].addr_port_text.data, | 1263 ngx_memcpy(lcf->peers->peers[0].addr_port_text.data, |
1218 lcf->upstream->host.data, len); | 1264 lcf->upstream->host.data, len); |
1219 | 1265 |
1220 lcf->peers->peers[0].addr_port_text.data[len++] = ':'; | 1266 lcf->peers->peers[0].addr_port_text.data[len++] = ':'; |
1221 | 1267 |
1222 ngx_cpystrn(lcf->peers->peers[0].addr_port_text.data + len, | 1268 ngx_memcpy(lcf->peers->peers[0].addr_port_text.data + len, |
1223 lcf->upstream->port_text.data, | 1269 lcf->upstream->port_text.data, |
1224 lcf->upstream->port_text.len + 1); | 1270 lcf->upstream->port_text.len); |
1225 } | 1271 } |
1226 | 1272 |
1227 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); | 1273 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); |
1228 | 1274 |
1229 lcf->upstream->location = &clcf->name; | 1275 lcf->upstream->location = &clcf->name; |