*/
| 344 | /* |
| 345 | */ |
| 346 | static int proxy_wstunnel_handler(request_rec *r, proxy_worker *worker, |
| 347 | proxy_server_conf *conf, |
| 348 | char *url, const char *proxyname, |
| 349 | apr_port_t proxyport) |
| 350 | { |
| 351 | proxyws_dir_conf *dconf = ap_get_module_config(r->per_dir_config, |
| 352 | &proxy_wstunnel_module); |
| 353 | int status; |
| 354 | char server_portstr[32]; |
| 355 | proxy_conn_rec *backend = NULL; |
| 356 | const char *upgrade; |
| 357 | char *scheme; |
| 358 | apr_pool_t *p = r->pool; |
| 359 | char *locurl = url; |
| 360 | apr_uri_t *uri; |
| 361 | int is_ssl = 0; |
| 362 | |
| 363 | if (can_fallback_to_proxy_http && dconf->fallback_to_proxy_http) { |
| 364 | ap_log_rerror(APLOG_MARK, APLOG_TRACE5, 0, r, "handler fallback"); |
| 365 | return DECLINED; |
| 366 | } |
| 367 | |
| 368 | if (ap_cstr_casecmpn(url, "wss:", 4) == 0) { |
| 369 | scheme = "WSS"; |
| 370 | is_ssl = 1; |
| 371 | } |
| 372 | else if (ap_cstr_casecmpn(url, "ws:", 3) == 0) { |
| 373 | scheme = "WS"; |
| 374 | } |
| 375 | else { |
| 376 | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02450) |
| 377 | "declining URL %s", url); |
| 378 | return DECLINED; |
| 379 | } |
| 380 | ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "serving URL %s", url); |
| 381 | |
| 382 | upgrade = apr_table_get(r->headers_in, "Upgrade"); |
| 383 | if (!upgrade || !ap_proxy_worker_can_upgrade(p, worker, upgrade, |
| 384 | "WebSocket")) { |
| 385 | const char *worker_upgrade = *worker->s->upgrade ? worker->s->upgrade |
| 386 | : "WebSocket"; |
| 387 | ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(02900) |
| 388 | "require upgrade for URL %s " |
| 389 | "(Upgrade header is %s, expecting %s)", |
| 390 | url, upgrade ? upgrade : "missing", worker_upgrade); |
| 391 | apr_table_setn(r->err_headers_out, "Connection", "Upgrade"); |
| 392 | apr_table_setn(r->err_headers_out, "Upgrade", worker_upgrade); |
| 393 | return HTTP_UPGRADE_REQUIRED; |
| 394 | } |
| 395 | |
| 396 | uri = apr_palloc(p, sizeof(*uri)); |
| 397 | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02451) "serving URL %s", url); |
| 398 | |
| 399 | /* create space for state information */ |
| 400 | status = ap_proxy_acquire_connection(scheme, &backend, worker, r->server); |
| 401 | if (status != OK) { |
| 402 | goto cleanup; |
| 403 | } |
nothing calls this directly
no test coverage detected