Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/root/version_history/current.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Minor Behavior Changes
* logging: changed default log format to `"[%Y-%m-%d %T.%e][%t][%l][%n] [%g:%#] %v"` and default value of :option:`--log-format-prefix-with-location` to `0`.
* logging: nghttp2 log messages no longer appear at trace level unless `ENVOY_NGHTTP2_TRACE` is set
in the environment.
* lua: changed the response body returned by `httpCall()` API to raw data. Previously, the returned data was string.
* router: added transport failure reason to response body when upstream reset happens. After this change, the response body will be of the form `upstream connect error or disconnect/reset before headers. reset reason:{}, transport failure reason:{}`.This behavior may be reverted by setting runtime feature `envoy.reloadable_features.http_transport_failure_reason_in_body` to false.
* router: now consumes all retry related headers to prevent them from being propagated to the upstream. This behavior may be reverted by setting runtime feature `envoy.reloadable_features.consume_all_retry_headers` to false.
* thrift_proxy: special characters {'\0', '\r', '\n'} will be stripped from thrift headers.
Expand Down
3 changes: 2 additions & 1 deletion source/extensions/filters/http/lua/lua_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ void StreamHandleWrapper::onSuccess(const Http::AsyncClient::Request&,

// TODO(mattklein123): Avoid double copy here.
if (response->body() != nullptr) {
lua_pushstring(coroutine_.luaState(), response->bodyAsString().c_str());
lua_pushlstring(coroutine_.luaState(), response->bodyAsString().data(),
response->body()->length());
} else {
lua_pushnil(coroutine_.luaState());
}
Expand Down
11 changes: 9 additions & 2 deletions test/extensions/filters/http/lua/lua_filter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,10 @@ TEST_F(LuaHttpFilterTest, HttpCall) {
for key, value in pairs(headers) do
request_handle:logTrace(key .. " " .. value)
end
request_handle:logTrace(string.len(body))
request_handle:logTrace(body)
request_handle:logTrace(string.byte(body, 5))
request_handle:logTrace(string.sub(body, 6, 8))
end
)EOF"};

Expand Down Expand Up @@ -828,9 +831,13 @@ TEST_F(LuaHttpFilterTest, HttpCall) {

Http::ResponseMessagePtr response_message(new Http::ResponseMessageImpl(
Http::ResponseHeaderMapPtr{new Http::TestResponseHeaderMapImpl{{":status", "200"}}}));
response_message->body() = std::make_unique<Buffer::OwnedImpl>("response");
const char response[8] = {'r', 'e', 's', 'p', '\0', 'n', 's', 'e'};
response_message->body() = std::make_unique<Buffer::OwnedImpl>(response, 8);
EXPECT_CALL(*filter_, scriptLog(spdlog::level::trace, StrEq(":status 200")));
EXPECT_CALL(*filter_, scriptLog(spdlog::level::trace, StrEq("response")));
EXPECT_CALL(*filter_, scriptLog(spdlog::level::trace, StrEq("8")));
EXPECT_CALL(*filter_, scriptLog(spdlog::level::trace, StrEq("resp")));
EXPECT_CALL(*filter_, scriptLog(spdlog::level::trace, StrEq("0")));
EXPECT_CALL(*filter_, scriptLog(spdlog::level::trace, StrEq("nse")));
EXPECT_CALL(decoder_callbacks_, continueDecoding());
callbacks->onBeforeFinalizeUpstreamSpan(child_span_, &response_message->headers());
callbacks->onSuccess(request, std::move(response_message));
Expand Down