Skip to content

Commit 796f618

Browse files
committed
When calling sendlocalreply in wasm, add an identifier in the detail.
1 parent dd103bb commit 796f618

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

source/extensions/common/wasm/context.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,8 +1906,15 @@ WasmResult Context::sendLocalResponse(uint32_t response_code, std::string_view b
19061906
if (local_reply_sent_) {
19071907
return;
19081908
}
1909+
#if defined(HIGRESS)
1910+
auto wasm_details = absl::StrFormat("via_wasm%s%s", plugin_ ? "::" + plugin()->name_ : "",
1911+
details.empty() ? "" : "::" + details);
1912+
decoder_callbacks_->sendLocalReply(static_cast<Envoy::Http::Code>(response_code), body_text,
1913+
modify_headers, grpc_status, wasm_details);
1914+
#else
19091915
decoder_callbacks_->sendLocalReply(static_cast<Envoy::Http::Code>(response_code), body_text,
19101916
modify_headers, grpc_status, details);
1917+
#endif
19111918
local_reply_sent_ = true;
19121919
});
19131920
}

test/extensions/common/wasm/wasm_test.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,8 +1442,13 @@ TEST_P(WasmCommonContextTest, DuplicateLocalReply) {
14421442
setupContext();
14431443
EXPECT_CALL(decoder_callbacks_, encodeHeaders_(_, _))
14441444
.WillOnce([this](Http::ResponseHeaderMap&, bool) { context().onResponseHeaders(0, false); });
1445+
#if defined(HIGRESS)
1446+
EXPECT_CALL(decoder_callbacks_, sendLocalReply(Envoy::Http::Code::OK, testing::Eq("body"), _, _,
1447+
testing::Eq("via_wasm::plugin_name::ok")));
1448+
#else
14451449
EXPECT_CALL(decoder_callbacks_,
14461450
sendLocalReply(Envoy::Http::Code::OK, testing::Eq("body"), _, _, testing::Eq("ok")));
1451+
#endif
14471452

14481453
// Create in-VM context.
14491454
context().onCreate();

0 commit comments

Comments
 (0)