@Test
public void setDispositionHeader()
{
ServletWebRequest webRequest = mock(ServletWebRequest.class);
MockHttpServletRequest httpRequest = mock(MockHttpServletRequest.class);
HttpServletResponse httpResponse = new MockHttpServletResponse(httpRequest);
ServletWebResponse response = new ServletWebResponse(webRequest, httpResponse);
response.setInlineHeader("name with spaces");
String header = httpResponse.getHeader("Content-Disposition");
assertEquals(
"inline; filename=\"name%20with%20spaces\"; filename*=UTF-8''name%20with%20spaces",
header);
// says: "name with bulgarian"
response.setInlineHeader("name with български");
header = httpResponse.getHeader("Content-Disposition");
assertEquals(
"inline; filename=\"name%20with%20%D0%B1%D1%8A%D0%BB%D0%B3%D0%B0%D1%80%D1%81%D0%BA%D0%B8\"; filename*=UTF-8''name%20with%20%D0%B1%D1%8A%D0%BB%D0%B3%D0%B0%D1%80%D1%81%D0%BA%D0%B8",
header);
response.setAttachmentHeader("name with spaces");
header = httpResponse.getHeader("Content-Disposition");
assertEquals(
"attachment; filename=\"name%20with%20spaces\"; filename*=UTF-8''name%20with%20spaces",
header);
// says: "name with bulgarian"
response.setAttachmentHeader("name with български");
header = httpResponse.getHeader("Content-Disposition");
assertEquals(
"attachment; filename=\"name%20with%20%D0%B1%D1%8A%D0%BB%D0%B3%D0%B0%D1%80%D1%81%D0%BA%D0%B8\"; filename*=UTF-8''name%20with%20%D0%B1%D1%8A%D0%BB%D0%B3%D0%B0%D1%80%D1%81%D0%BA%D0%B8",
header);
}