Skip to content
Open
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 core/src/main/java/feign/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ public boolean isBinary() {
}

public static Body create(String data) {
return new Body(data.getBytes());
return create(data, Util.UTF_8);
}

public static Body create(String data, Charset charset) {
Expand Down
37 changes: 37 additions & 0 deletions core/src/test/java/feign/RequestTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright © 2012 The Feign Authors (feign@commonhaus.dev)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package feign;

import static feign.Util.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;

import feign.Request.Body;
import org.junit.jupiter.api.Test;

public class RequestTest {

@Test
void stringBodyIsEncodedWithUtf8NotThePlatformDefault() {
String content = "spécial-çhars-€";

Body body = Body.create(content);

assertThat(body.asBytes()).isEqualTo(content.getBytes(UTF_8));
assertThat(body.getEncoding()).hasValue(UTF_8);
assertThat(body.isBinary()).isFalse();
assertThat(body.asString()).isEqualTo(content);
}
}