INT-3120: Remove Accept-Charset from Response

`StringHttpMessageConverter` adds `Accept-Charset` header by default.
By RFC 2616 `Accept-Charset` is a Request header,
so it won't be presented in the response.

Turn off `writeAcceptCharset` in the `HttpRequestHandlingEndpointSupport`.

JIRA: https://jira.springsource.org/browse/INT-3120
This commit is contained in:
Artem Bilan
2013-09-12 11:37:44 +03:00
committed by Gary Russell
parent 937ac9647a
commit 5cb64f81f6
2 changed files with 8 additions and 1 deletions

View File

@@ -94,6 +94,7 @@ import org.springframework.web.util.UrlPathHelper;
* @author Mark Fisher
* @author Oleg Zhurakousky
* @author Gary Russell
* @author Artem Bilan
* @since 2.0
*/
public abstract class HttpRequestHandlingEndpointSupport extends MessagingGatewaySupport
@@ -147,7 +148,9 @@ public abstract class HttpRequestHandlingEndpointSupport extends MessagingGatewa
this.expectReply = expectReply;
this.messageConverters.add(new MultipartAwareFormHttpMessageConverter());
this.messageConverters.add(new ByteArrayHttpMessageConverter());
this.messageConverters.add(new StringHttpMessageConverter());
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
stringHttpMessageConverter.setWriteAcceptCharset(false);
this.messageConverters.add(stringHttpMessageConverter);
this.messageConverters.add(new ResourceHttpMessageConverter());
this.messageConverters.add(new SourceHttpMessageConverter());
if (jaxb2Present) {

View File

@@ -16,6 +16,7 @@
package org.springframework.integration.http.inbound;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.mock;
@@ -53,6 +54,7 @@ import org.springframework.util.SerializationUtils;
* @author Mark Fisher
* @author Gary Russell
* @author Gunnar Hillert
* @author Artem Bilan
* @since 2.0
*/
public class HttpRequestHandlingMessagingGatewayTests {
@@ -151,6 +153,8 @@ public class HttpRequestHandlingMessagingGatewayTests {
MockHttpServletResponse response = new MockHttpServletResponse();
gateway.handleRequest(request, response);
assertEquals("HELLO", response.getContentAsString());
//INT-3120
assertNull(response.getHeader("Accept-Charset"));
}
@Test