Skip to content

Commit 19837d4

Browse files
committed
header_rewrite: address review feedback on set-body origin
Replace the api_hooks.get() clause in the SERVER_READ bypass with a cur_hook_id check, which is scope-agnostic (works for global, session, and txn hooks alike) and a precise per-transaction statement of "the plugin that just ran was on a response-stage hook." Strip explanatory comments where the code already speaks for itself.
1 parent 826e1bc commit 19837d4

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

src/proxy/http/HttpSM.cc

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,31 +1687,25 @@ HttpSM::handle_api_return()
16871687

16881688
switch (t_state.next_action) {
16891689
case HttpTransact::StateMachineAction_t::TRANSFORM_READ: {
1690-
// A plugin has installed an internal response body (TSHttpTxnErrorBodySet()).
1691-
// In this branch we bypass transform streaming and switch to internal transfer.
16921690
if (t_state.internal_msg_buffer && !t_state.api_server_request_body_set && t_state.hdr_info.server_response.valid()) {
16931691
SMDbg(dbg_ctl_http, "plugin set internal body, bypassing response transform for internal transfer");
16941692
t_state.api_info.cache_untransformed = true;
1695-
// If a tunnel was already set up for transform I/O, shut it down before we re-route.
16961693
if (tunnel.is_tunnel_active()) {
16971694
tunnel.kill_tunnel();
16981695
}
1699-
// Drop transform VC table state because this path no longer drives transform reads.
17001696
if (transform_info.entry != nullptr) {
17011697
vc_table.cleanup_entry(transform_info.entry);
17021698
transform_info.entry = nullptr;
17031699
}
17041700
transform_info.vc = nullptr;
1705-
// Some downstream paths still read client_response; seed it from transform_response when missing.
1701+
// Downstream paths read client_response; seed from transform_response when missing.
17061702
if (t_state.hdr_info.client_response.valid() == 0 && t_state.hdr_info.transform_response.valid()) {
17071703
t_state.hdr_info.client_response.create(HTTPType::RESPONSE);
17081704
t_state.hdr_info.client_response.copy(&t_state.hdr_info.transform_response);
17091705
}
1710-
// The server session is not needed for internal body transfer if it was never tunneled.
17111706
if (server_entry != nullptr && server_entry->in_tunnel == false) {
17121707
release_server_session();
17131708
}
1714-
// Serve the plugin-provided body through the internal tunnel handler.
17151709
setup_internal_transfer(&HttpSM::tunnel_handler);
17161710
} else {
17171711
HttpTunnelProducer *p = setup_transfer_from_transform();
@@ -1752,10 +1746,7 @@ HttpSM::handle_api_return()
17521746
setup_blind_tunnel(true, initial_data);
17531747
} else if (t_state.internal_msg_buffer && !t_state.api_server_request_body_set && t_state.hdr_info.server_response.valid() &&
17541748
plugin_tunnel == nullptr &&
1755-
(api_hooks.get(TS_HTTP_READ_RESPONSE_HDR_HOOK) != nullptr ||
1756-
api_hooks.get(TS_HTTP_SEND_RESPONSE_HDR_HOOK) != nullptr)) {
1757-
// A plugin replaced the origin response body via TSHttpTxnErrorBodySet().
1758-
// Serve the synthetic body before entering the response body tunnel.
1749+
(cur_hook_id == TS_HTTP_READ_RESPONSE_HDR_HOOK || cur_hook_id == TS_HTTP_SEND_RESPONSE_HDR_HOOK)) {
17591750
SMDbg(dbg_ctl_http, "plugin set internal body, using internal transfer instead of server tunnel");
17601751
if (server_entry != nullptr && server_entry->in_tunnel == false) {
17611752
release_server_session();

0 commit comments

Comments
 (0)