Merge branch 'master' of ssh://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project

This commit is contained in:
Jan Bartel 2012-04-26 08:53:58 +10:00
commit 1169319e4a
2 changed files with 42 additions and 2 deletions

View File

@ -717,9 +717,16 @@ public class Response implements HttpServletResponse
{
_characterEncoding=null;
if (_cachedMimeType!=null)
_connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_cachedMimeType);
_contentType=_cachedMimeType.toString();
else if (_mimeType!=null)
_contentType=_mimeType;
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

View File

@ -129,6 +129,39 @@ public class ResponseTest
response.setContentType("text/json");
response.getWriter();
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