void HttpSM::handle_api_return() Figures out what to do after calling api callouts have finished. This is messy and I would like to come up with a cleaner way to handle the api return. The way we are doing things also makes a mess of set_next_state()
| 1567 | // mess of set_next_state() |
| 1568 | // |
| 1569 | void |
| 1570 | HttpSM::handle_api_return() |
| 1571 | { |
| 1572 | switch (t_state.api_next_action) { |
| 1573 | case HttpTransact::SM_ACTION_API_SM_START: { |
| 1574 | NetVConnection *netvc = _ua.get_txn()->get_netvc(); |
| 1575 | auto *tts = netvc->get_service<TLSTunnelSupport>(); |
| 1576 | bool forward_dest = tts != nullptr && tts->is_decryption_needed(); |
| 1577 | if (t_state.client_info.port_attribute == HttpProxyPort::TRANSPORT_BLIND_TUNNEL || forward_dest) { |
| 1578 | setup_blind_tunnel_port(); |
| 1579 | } else { |
| 1580 | setup_client_read_request_header(); |
| 1581 | } |
| 1582 | return; |
| 1583 | } |
| 1584 | case HttpTransact::SM_ACTION_API_CACHE_LOOKUP_COMPLETE: |
| 1585 | case HttpTransact::SM_ACTION_API_READ_CACHE_HDR: |
| 1586 | if (t_state.api_cleanup_cache_read && t_state.api_update_cached_object != HttpTransact::UPDATE_CACHED_OBJECT_PREPARE) { |
| 1587 | t_state.api_cleanup_cache_read = false; |
| 1588 | t_state.cache_info.object_read = nullptr; |
| 1589 | t_state.request_sent_time = UNDEFINED_TIME; |
| 1590 | t_state.response_received_time = UNDEFINED_TIME; |
| 1591 | cache_sm.close_read(); |
| 1592 | transform_cache_sm.close_read(); |
| 1593 | } |
| 1594 | // fallthrough |
| 1595 | |
| 1596 | case HttpTransact::SM_ACTION_API_PRE_REMAP: |
| 1597 | case HttpTransact::SM_ACTION_API_POST_REMAP: |
| 1598 | case HttpTransact::SM_ACTION_API_READ_REQUEST_HDR: |
| 1599 | case HttpTransact::SM_ACTION_REQUEST_BUFFER_READ_COMPLETE: |
| 1600 | case HttpTransact::SM_ACTION_API_OS_DNS: |
| 1601 | case HttpTransact::SM_ACTION_API_READ_RESPONSE_HDR: |
| 1602 | call_transact_and_set_next_state(nullptr); |
| 1603 | return; |
| 1604 | case HttpTransact::SM_ACTION_API_TUNNEL_START: |
| 1605 | // Finished the Tunnel start callback. Go ahead and do the HandleBlindTunnel |
| 1606 | call_transact_and_set_next_state(HttpTransact::HandleBlindTunnel); |
| 1607 | return; |
| 1608 | case HttpTransact::SM_ACTION_API_SEND_REQUEST_HDR: |
| 1609 | setup_server_send_request(); |
| 1610 | return; |
| 1611 | case HttpTransact::SM_ACTION_API_SEND_RESPONSE_HDR: |
| 1612 | // Set back the inactivity timeout |
| 1613 | if (_ua.get_txn()) { |
| 1614 | _ua.get_txn()->set_inactivity_timeout(HRTIME_SECONDS(t_state.txn_conf->transaction_no_activity_timeout_in)); |
| 1615 | } |
| 1616 | |
| 1617 | // We only follow 3xx when redirect_in_process == false. Otherwise the redirection has already been launched (in |
| 1618 | // SM_ACTION_SERVER_READ).redirect_in_process is set before this logic if we need more direction. |
| 1619 | // This redirection is only used with the build_error_response. Then, the redirection_tries will be increased by |
| 1620 | // state_read_server_response_header and never get into this logic again. |
| 1621 | if (enable_redirection && !t_state.redirect_info.redirect_in_process && is_redirect_required()) { |
| 1622 | do_redirect(); |
| 1623 | } |
| 1624 | // we have further processing to do |
| 1625 | // based on what t_state.next_action is |
| 1626 | break; |
nothing calls this directly
no test coverage detected