use of org.apache.wicket.protocol.http.mock.MockHttpServletResponse in project wicket by apache.
the class ServletWebResponseTest method setDispositionHeader.
/**
* WICKET-4934 DownloadLink uses wrong encoding for spaces/non-ASCII characters
*/
@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 and;,");
String header = httpResponse.getHeader("Content-Disposition");
assertEquals("inline; filename=\"name%20with%20spaces%20and%3B%2C\"; filename*=UTF-8''name%20with%20spaces%20and%3B%2C", 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);
}
Aggregations