| 2401 | } |
| 2402 | |
| 2403 | AP_DECLARE(apr_status_t) ap_get_protocol_upgrades(conn_rec *c, request_rec *r, |
| 2404 | server_rec *s, int report_all, |
| 2405 | const apr_array_header_t **pupgrades) |
| 2406 | { |
| 2407 | apr_pool_t *pool = r? r->pool : c->pool; |
| 2408 | core_server_config *conf; |
| 2409 | const char *existing; |
| 2410 | apr_array_header_t *upgrades = NULL; |
| 2411 | |
| 2412 | if (!s) { |
| 2413 | s = (r? r->server : c->base_server); |
| 2414 | } |
| 2415 | conf = ap_get_core_module_config(s->module_config); |
| 2416 | |
| 2417 | if (conf->protocols->nelts > 0) { |
| 2418 | existing = ap_get_protocol(c); |
| 2419 | if (conf->protocols->nelts > 1 |
| 2420 | || !ap_array_str_contains(conf->protocols, existing)) { |
| 2421 | int i; |
| 2422 | |
| 2423 | /* possibly more than one choice or one, but not the |
| 2424 | * existing. (TODO: maybe 426 and Upgrade then?) */ |
| 2425 | upgrades = apr_array_make(pool, conf->protocols->nelts + 1, |
| 2426 | sizeof(char *)); |
| 2427 | for (i = 0; i < conf->protocols->nelts; i++) { |
| 2428 | const char *p = APR_ARRAY_IDX(conf->protocols, i, char *); |
| 2429 | if (strcmp(existing, p)) { |
| 2430 | /* not the one we have and possible, add in this order */ |
| 2431 | APR_ARRAY_PUSH(upgrades, const char*) = p; |
| 2432 | } |
| 2433 | else if (!report_all) { |
| 2434 | break; |
| 2435 | } |
| 2436 | } |
| 2437 | } |
| 2438 | } |
| 2439 | |
| 2440 | *pupgrades = upgrades; |
| 2441 | return APR_SUCCESS; |
| 2442 | } |
| 2443 | |
| 2444 | AP_DECLARE(const char *) ap_select_protocol(conn_rec *c, request_rec *r, |
| 2445 | server_rec *s, |
no test coverage detected