| 1341 | } |
| 1342 | |
| 1343 | void |
| 1344 | HttpTransact::handle_websocket_upgrade_pre_remap(State *s) |
| 1345 | { |
| 1346 | TxnDbg(dbg_ctl_http_trans_websocket_upgrade_pre_remap, "Prepping transaction before remap."); |
| 1347 | |
| 1348 | /* |
| 1349 | * We will use this opportunity to set everything up so that during the remap stage we can deal with |
| 1350 | * ws:// and wss:// remap rules, and then we will take over again post remap. |
| 1351 | */ |
| 1352 | s->is_websocket = true; |
| 1353 | s->post_remap_upgrade_return_point = HttpTransact::handle_websocket_upgrade_post_remap; |
| 1354 | |
| 1355 | /* let's modify the url scheme to be wss or ws, so remapping will happen as expected */ |
| 1356 | URL *url = s->hdr_info.client_request.url_get(); |
| 1357 | if (url->scheme_get_wksidx() == URL_WKSIDX_HTTP) { |
| 1358 | TxnDbg(dbg_ctl_http_trans_websocket_upgrade_pre_remap, "Changing scheme to WS for remapping."); |
| 1359 | url->scheme_set(URL_SCHEME_WS, URL_LEN_WS); |
| 1360 | } else if (url->scheme_get_wksidx() == URL_WKSIDX_HTTPS) { |
| 1361 | TxnDbg(dbg_ctl_http_trans_websocket_upgrade_pre_remap, "Changing scheme to WSS for remapping."); |
| 1362 | url->scheme_set(URL_SCHEME_WSS, URL_LEN_WSS); |
| 1363 | } else { |
| 1364 | TxnDbg(dbg_ctl_http_trans_websocket_upgrade_pre_remap, "Invalid scheme for websocket upgrade"); |
| 1365 | build_error_response(s, HTTP_STATUS_BAD_REQUEST, "Invalid Upgrade Request", "request#syntax_error"); |
| 1366 | TRANSACT_RETURN(SM_ACTION_SEND_ERROR_CACHE_NOOP, nullptr); |
| 1367 | } |
| 1368 | |
| 1369 | TRANSACT_RETURN(SM_ACTION_API_PRE_REMAP, HttpTransact::PerformRemap); |
| 1370 | } |
| 1371 | |
| 1372 | void |
| 1373 | HttpTransact::handle_websocket_upgrade_post_remap(State *s) |
nothing calls this directly
no test coverage detected