handle setting null charset
This commit is contained in:
parent
fbac246a41
commit
925340c72b
|
@ -717,9 +717,16 @@ public class Response implements HttpServletResponse
|
||||||
{
|
{
|
||||||
_characterEncoding=null;
|
_characterEncoding=null;
|
||||||
if (_cachedMimeType!=null)
|
if (_cachedMimeType!=null)
|
||||||
_connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_cachedMimeType);
|
_contentType=_cachedMimeType.toString();
|
||||||
|
else if (_mimeType!=null)
|
||||||
|
_contentType=_mimeType;
|
||||||
else
|
else
|
||||||
_connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_mimeType);
|
_contentType=null;
|
||||||
|
|
||||||
|
if (_contentType==null)
|
||||||
|
_connection.getResponseFields().remove(HttpHeaders.CONTENT_TYPE_BUFFER);
|
||||||
|
else
|
||||||
|
_connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -129,6 +129,39 @@ public class ResponseTest
|
||||||
response.setContentType("text/json");
|
response.setContentType("text/json");
|
||||||
response.getWriter();
|
response.getWriter();
|
||||||
assertEquals("text/json;charset=UTF-8", response.getContentType());
|
assertEquals("text/json;charset=UTF-8", response.getContentType());
|
||||||
|
|
||||||
|
response.recycle();
|
||||||
|
response.setCharacterEncoding("xyz");
|
||||||
|
response.setContentType("foo/bar");
|
||||||
|
assertEquals("foo/bar;charset=xyz", response.getContentType());
|
||||||
|
|
||||||
|
response.recycle();
|
||||||
|
response.setContentType("foo/bar");
|
||||||
|
response.setCharacterEncoding("xyz");
|
||||||
|
assertEquals("foo/bar;charset=xyz", response.getContentType());
|
||||||
|
|
||||||
|
response.recycle();
|
||||||
|
response.setCharacterEncoding("xyz");
|
||||||
|
response.setContentType("foo/bar;charset=abc");
|
||||||
|
assertEquals("foo/bar;charset=abc", response.getContentType());
|
||||||
|
|
||||||
|
response.recycle();
|
||||||
|
response.setContentType("foo/bar;charset=abc");
|
||||||
|
response.setCharacterEncoding("xyz");
|
||||||
|
assertEquals("foo/bar;charset=xyz", response.getContentType());
|
||||||
|
|
||||||
|
response.recycle();
|
||||||
|
response.setCharacterEncoding("xyz");
|
||||||
|
response.setContentType("foo/bar");
|
||||||
|
response.setCharacterEncoding(null);
|
||||||
|
assertEquals("foo/bar", response.getContentType());
|
||||||
|
|
||||||
|
response.recycle();
|
||||||
|
response.setCharacterEncoding("xyz");
|
||||||
|
response.setCharacterEncoding(null);
|
||||||
|
response.setContentType("foo/bar");
|
||||||
|
assertEquals("foo/bar", response.getContentType());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue