Klaus Demo nginx / 164abfb
fix case proxy_pass URL is evaluted to http://host?args Igor Sysoev 13 years ago
2 changed file(s) with 30 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
250250 static ngx_int_t
251251 ngx_parse_inet_url(ngx_pool_t *pool, ngx_url_t *u)
252252 {
253 u_char *p, *host, *port, *last, *uri;
253 u_char *p, *host, *port, *last, *uri, *args;
254254 size_t len;
255255 ngx_int_t n;
256256 struct hostent *h;
264264 port = ngx_strlchr(host, last, ':');
265265
266266 uri = ngx_strlchr(host, last, '/');
267
268 args = ngx_strlchr(host, last, '?');
269
270 if (args) {
271 if (uri == NULL) {
272 uri = args;
273
274 } else if (args < uri) {
275 uri = args;
276 }
277 }
267278
268279 if (uri) {
269280 if (u->listen || !u->uri_part) {
535535 ngx_http_proxy_eval(ngx_http_request_t *r, ngx_http_proxy_ctx_t *ctx,
536536 ngx_http_proxy_loc_conf_t *plcf)
537537 {
538 size_t add;
539 u_short port;
540 ngx_str_t proxy;
541 ngx_url_t u;
538 u_char *p;
539 size_t add;
540 u_short port;
541 ngx_str_t proxy;
542 ngx_url_t u;
542543
543544 if (ngx_http_script_run(r, &proxy, plcf->proxy_lengths->elts, 0,
544545 plcf->proxy_values->elts)
586587 }
587588
588589 return NGX_ERROR;
590 }
591
592 if (u.uri.len && u.uri.data[0] == '?') {
593 p = ngx_pnalloc(r->pool, u.uri.len + 1);
594 if (p == NULL) {
595 return NGX_ERROR;
596 }
597
598 *p++ = '/';
599 ngx_memcpy(p, u.uri.data, u.uri.len);
600
601 u.uri.len++;
602 u.uri.data = p - 1;
589603 }
590604
591605 if (ngx_http_proxy_set_vars(r->pool, &u, &ctx->vars) != NGX_OK) {