| 270 | } |
| 271 | |
| 272 | static proxy_worker *find_session_route(proxy_balancer *balancer, |
| 273 | request_rec *r, |
| 274 | char **route, |
| 275 | const char **sticky_used, |
| 276 | char **url) |
| 277 | { |
| 278 | proxy_worker *worker = NULL; |
| 279 | char *url_with_qs; |
| 280 | |
| 281 | if (!*balancer->s->sticky) |
| 282 | return NULL; |
| 283 | /* |
| 284 | * The route might be contained in the query string and *url is not |
| 285 | * supposed to contain the query string. Hence add it temporarily if |
| 286 | * present. |
| 287 | */ |
| 288 | if (r->args) { |
| 289 | url_with_qs = apr_pstrcat(r->pool, *url, "?", r->args, NULL); |
| 290 | } |
| 291 | else { |
| 292 | url_with_qs = *url; |
| 293 | } |
| 294 | /* Try to find the sticky route inside url */ |
| 295 | *route = get_path_param(r->pool, url_with_qs, balancer->s->sticky_path, balancer->s->scolonsep); |
| 296 | if (*route) { |
| 297 | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01159) |
| 298 | "Found value %s for stickysession %s", |
| 299 | *route, balancer->s->sticky_path); |
| 300 | *sticky_used = balancer->s->sticky_path; |
| 301 | } |
| 302 | else { |
| 303 | *route = get_cookie_param(r, balancer->s->sticky); |
| 304 | if (*route) { |
| 305 | *sticky_used = balancer->s->sticky; |
| 306 | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01160) |
| 307 | "Found value %s for stickysession %s", |
| 308 | *route, balancer->s->sticky); |
| 309 | } |
| 310 | } |
| 311 | /* |
| 312 | * If we found a value for stickysession, find the first '.' (or whatever |
| 313 | * sticky_separator is set to) within. Everything after '.' (if present) |
| 314 | * is our route. |
| 315 | */ |
| 316 | if ((*route) && (balancer->s->sticky_separator != 0) && ((*route = strchr(*route, balancer->s->sticky_separator)) != NULL )) |
| 317 | (*route)++; |
| 318 | if ((*route) && (**route)) { |
| 319 | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01161) "Found route %s", *route); |
| 320 | /* We have a route in path or in cookie |
| 321 | * Find the worker that has this route defined. |
| 322 | */ |
| 323 | worker = find_route_worker(balancer, *route, r, 1); |
| 324 | if (worker && strcmp(*route, worker->s->route)) { |
| 325 | /* |
| 326 | * Notice that the route of the worker chosen is different from |
| 327 | * the route supplied by the client. |
| 328 | */ |
| 329 | apr_table_setn(r->subprocess_env, "BALANCER_ROUTE_CHANGED", "1"); |
no test coverage detected