mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
Tests: Fix mockwebserver to parse incoming http bodies as UTF8
By not specifying a charset this used the system charset and led to breaking tests under windows. relates elastic/x-pack-elasticsearch#3498 Original commit: elastic/x-pack-elasticsearch@17d415ebbd
This commit is contained in:
parent
f80f1dd268
commit
1d3c622746
@ -179,7 +179,7 @@ public class MockWebServer implements Closeable {
|
||||
private MockRequest createRequest(HttpExchange exchange) throws IOException {
|
||||
MockRequest request = new MockRequest(exchange.getRequestMethod(), exchange.getRequestURI(), exchange.getRequestHeaders());
|
||||
if (exchange.getRequestBody() != null) {
|
||||
String body = Streams.copyToString(new InputStreamReader(exchange.getRequestBody()));
|
||||
String body = Streams.copyToString(new InputStreamReader(exchange.getRequestBody(), StandardCharsets.UTF_8));
|
||||
if (Strings.isEmpty(body) == false) {
|
||||
request.setBody(body);
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import org.apache.http.HttpHeaders;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.logging.log4j.message.ParameterizedMessage;
|
||||
import org.apache.logging.log4j.util.Supplier;
|
||||
import org.apache.lucene.util.Constants;
|
||||
import org.elasticsearch.common.settings.MockSecureSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.ByteSizeUnit;
|
||||
@ -499,7 +498,6 @@ public class HttpClientTests extends ESTestCase {
|
||||
}
|
||||
|
||||
public void testThatBodyWithUTF8Content() throws Exception {
|
||||
assumeTrue("This test fails under windows, disabled temporary",Constants.WINDOWS == false);
|
||||
String body = "title あいうえお";
|
||||
webServer.enqueue(new MockResponse().setResponseCode(200).setBody(body));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user