Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 4 additions & 1 deletion deps/rabbitmq_tracing/src/rabbit_tracing_wm_file.erl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ serve(ReqData, Context) ->
Content = rabbit_tracing_util:apply_on_node(ReqData, Context,
rabbit_tracing_wm_file,
serve, [Name]),
{Content, ReqData, Context}.
ReqWithCharset = cowboy_req:set_resp_header(<<"content-type">>,
<<"text/plain; charset=utf-8">>,
ReqData),
{Content, ReqWithCharset, Context}.

serve(Name) ->
Path = rabbit_tracing_files:full_path(Name),
Expand Down
32 changes: 31 additions & 1 deletion deps/rabbitmq_tracing/test/rabbit_tracing_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ groups() ->
[
{non_parallel_tests, [], [
tracing_test,
tracing_validation_test
tracing_validation_test,
trace_file_content_type_test
]}
].

Expand Down Expand Up @@ -128,6 +129,35 @@ tracing_validation_test(Config) ->
http_delete(Config, Path, ?NO_CONTENT),
ok.

trace_file_content_type_test(Config) ->
case filelib:is_dir(?LOG_DIR) of
true -> {ok, Files} = file:list_dir(?LOG_DIR),
[ok = file:delete(?LOG_DIR ++ F) || F <- Files];
_ -> ok
end,

Args = #{format => <<"text">>,
pattern => <<"#">>},
http_put(Config, "/traces/%2f/test-charset", Args, ?CREATED),

Ch = rabbit_ct_client_helpers:open_channel(Config),
amqp_channel:cast(Ch, #'basic.publish'{ exchange = <<"amq.topic">>,
routing_key = <<"key">> },
#amqp_msg{props = #'P_basic'{},
payload = <<"Test message">>}),
rabbit_ct_client_helpers:close_channel(Ch),

timer:sleep(100),

http_delete(Config, "/traces/%2f/test-charset", ?NO_CONTENT),
{ok, {{_HTTP, 200, _}, Headers, _Body}} =
req(Config, get, "/trace-files/test-charset.log", [auth_header("guest", "guest")]),
ContentType = proplists:get_value("content-type", Headers),
?assertEqual(match, re:run(ContentType, "text/plain", [{capture, none}])),
?assertEqual(match, re:run(ContentType, "charset=utf-8", [{capture, none}])),
http_delete(Config, "/trace-files/test-charset.log", ?NO_CONTENT),
ok.

%%---------------------------------------------------------------------------
%% TODO: Below is copied from rabbit_mgmt_test_http,
%% should be moved to use rabbit_mgmt_test_util once rabbitmq_management
Expand Down
10 changes: 10 additions & 0 deletions release-notes/4.3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ compared to other versions.
GitHub issue: [#14923](https://github.com/rabbitmq/rabbitmq-server/discussions/14923)


### Tracing Plugin

#### Bug Fixes

* Trace file downloads now correctly display Cyrillic and other Unicode characters in browsers
by setting `charset=utf-8` in the `Content-Type` header.

GitHub issue: [#13952](https://github.com/rabbitmq/rabbitmq-server/issues/13952)


### Shovel Plugin

#### Bug Fixes
Expand Down