Skip to content

Commit

Permalink
fixes #2330 update response tranformer interceptor to use explicit UT…
Browse files Browse the repository at this point in the history
…F-8 for response body (#2331)
  • Loading branch information
stevehu authored Aug 23, 2024
1 parent 3c8e7c9 commit 7cf6c57
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.slf4j.LoggerFactory;

import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -183,7 +184,9 @@ public void handleRequest(HttpServerExchange exchange) throws Exception {
if (responseBody != null) {
// copy transformed buffer to the attachment
var dest = exchange.getAttachment(AttachmentConstants.BUFFERED_RESPONSE_DATA_KEY);
BuffersUtils.transfer(ByteBuffer.wrap(responseBody.getBytes()), dest, exchange);
// here we convert back the response body to byte array. Need to find out the default charset.
if(logger.isTraceEnabled()) logger.trace("Default Charset {}", Charset.defaultCharset());
BuffersUtils.transfer(ByteBuffer.wrap(responseBody.getBytes(StandardCharsets.UTF_8)), dest, exchange);
}
break;
}
Expand Down

0 comments on commit 7cf6c57

Please sign in to comment.