fix case proxy_pass URL is evaluted to http://host?args
Igor Sysoev
13 years ago
250 | 250 |
static ngx_int_t
|
251 | 251 |
ngx_parse_inet_url(ngx_pool_t *pool, ngx_url_t *u)
|
252 | 252 |
{
|
253 | |
u_char *p, *host, *port, *last, *uri;
|
|
253 |
u_char *p, *host, *port, *last, *uri, *args;
|
254 | 254 |
size_t len;
|
255 | 255 |
ngx_int_t n;
|
256 | 256 |
struct hostent *h;
|
|
264 | 264 |
port = ngx_strlchr(host, last, ':');
|
265 | 265 |
|
266 | 266 |
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 |
}
|
267 | 278 |
|
268 | 279 |
if (uri) {
|
269 | 280 |
if (u->listen || !u->uri_part) {
|
535 | 535 |
ngx_http_proxy_eval(ngx_http_request_t *r, ngx_http_proxy_ctx_t *ctx,
|
536 | 536 |
ngx_http_proxy_loc_conf_t *plcf)
|
537 | 537 |
{
|
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;
|
542 | 543 |
|
543 | 544 |
if (ngx_http_script_run(r, &proxy, plcf->proxy_lengths->elts, 0,
|
544 | 545 |
plcf->proxy_values->elts)
|
|
586 | 587 |
}
|
587 | 588 |
|
588 | 589 |
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;
|
589 | 603 |
}
|
590 | 604 |
|
591 | 605 |
if (ngx_http_proxy_set_vars(r->pool, &u, &ctx->vars) != NGX_OK) {
|