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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ plugins {
}

group 'ee.bitweb'
version '4.0.3'
version '4.0.4'
java {
sourceCompatibility = '17'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ String getBodyString(RequestBody body) throws IOException {
assert charSet != null;
var bodyString = buffer.readString(charSet);

if (body.contentLength() == -1 || body.contentLength() > maxLoggableRequestSize) {
if (body.contentLength() == -1 || bodyString.length() > maxLoggableRequestSize) {
return "%s ... Content size: %s characters".formatted(
bodyString.substring(0, maxLoggableRequestSize),
body.contentLength()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,14 @@ void requestContentIsReturnedInFull() throws MalformedURLException {
Mockito.verify(request, Mockito.times(1)).headers();
Mockito.verifyNoInteractions(requestBody);
}

@Test
@DisplayName("Request content bytes count differs from character count")
void requestContentBytesCountDiffersFromCharacterCount() throws IOException {
// "õäöü" is 4 characters, but 8 bytes
var customBody = RequestBody.create("õäöü", MediaType.parse("text/plain"));
var mapper = new RetrofitRequestBodyMapper(5, Set.of());

assertEquals("õäöü", mapper.getBodyString(customBody));
}
}
Loading