Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert byte array to string for logging in ProxyResponse #578

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andythsu
Copy link
Member

Description

byte[] cannot get logged. Changing it to actual String type for logging

Additional context and related issues

Release notes

(X) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

* Fix some things. ({issue}`issuenumber`)

@cla-bot cla-bot bot added the cla-signed label Dec 21, 2024
@ebyhr ebyhr requested a review from oneonestar December 21, 2024 02:42
@@ -38,7 +39,7 @@ public ProxyResponse handleException(Request request, Exception exception)
public ProxyResponse handle(Request request, Response response)
{
try {
return new ProxyResponse(response.getStatusCode(), response.getHeaders(), toByteArray(response.getInputStream()));
return new ProxyResponse(response.getStatusCode(), response.getHeaders(), new String(toByteArray(response.getInputStream()), StandardCharsets.UTF_8));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/google/guava/blob/master/guava/src/com/google/common/io/ByteStreams.java#L234-L243

Java 9+ users: use {@code in#readAllBytes()} instead.

I think we should use readAllBytes() instead of toByteArray().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants