Concrete MediaType check in StringHttpMessageConverter
Closes gh-23287
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -131,4 +131,16 @@ public class StringHttpMessageConverterTests {
|
||||
assertThat(headers.getAcceptCharset().isEmpty()).isTrue();
|
||||
}
|
||||
|
||||
@Test // gh-24283
|
||||
public void writeWithWildCardMediaType() throws IOException {
|
||||
String body = "Hello World";
|
||||
this.converter.write(body, MediaType.ALL, this.outputMessage);
|
||||
|
||||
HttpHeaders headers = this.outputMessage.getHeaders();
|
||||
assertThat(this.outputMessage.getBodyAsString(StandardCharsets.US_ASCII)).isEqualTo(body);
|
||||
assertThat(headers.getContentType()).isEqualTo(new MediaType("text", "plain", StandardCharsets.ISO_8859_1));
|
||||
assertThat(headers.getContentLength()).isEqualTo(body.getBytes().length);
|
||||
assertThat(headers.getAcceptCharset().isEmpty()).isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user