diff --git a/flow-server/src/main/java/com/vaadin/flow/server/UnsupportedBrowserHandler.java b/flow-server/src/main/java/com/vaadin/flow/server/UnsupportedBrowserHandler.java index c38ecb64ed4..cb6554104f8 100644 --- a/flow-server/src/main/java/com/vaadin/flow/server/UnsupportedBrowserHandler.java +++ b/flow-server/src/main/java/com/vaadin/flow/server/UnsupportedBrowserHandler.java @@ -18,6 +18,8 @@ import java.io.IOException; import java.io.Writer; +import com.vaadin.flow.shared.ApplicationConstants; + /** * A {@link RequestHandler} that presents an informative page if the browser in * use is unsupported. @@ -104,6 +106,9 @@ protected void writeBrowserTooOldPage(VaadinRequest request, Writer page = response.getWriter(); WebBrowser browser = VaadinSession.getCurrent().getBrowser(); + response.setContentType( + ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8); + // @formatter:off page.write( "" diff --git a/flow-server/src/test/java/com/vaadin/flow/server/UnsupportedBrowserHandlerTest.java b/flow-server/src/test/java/com/vaadin/flow/server/UnsupportedBrowserHandlerTest.java index 340ce4e04fc..8d819841c0c 100644 --- a/flow-server/src/test/java/com/vaadin/flow/server/UnsupportedBrowserHandlerTest.java +++ b/flow-server/src/test/java/com/vaadin/flow/server/UnsupportedBrowserHandlerTest.java @@ -9,6 +9,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.Mockito; +import com.vaadin.flow.shared.ApplicationConstants; import com.vaadin.tests.util.MockDeploymentConfiguration; public class UnsupportedBrowserHandlerTest { @@ -72,6 +73,9 @@ public void testUnsupportedBrowserHandler_tooOldBrowser_returnsUnsupportedBrowse Assert.assertTrue("Unsupported browser page not used", pageCapture.getValue().contains( "I'm sorry, but your browser is not supported")); + + Mockito.verify(response).setContentType( + ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8); } @Test @@ -94,6 +98,15 @@ public void testUnsupportedBrowserHandler_validBrowserWithForceReloadCookie_does Mockito.verify(writer, Mockito.never()).write(Mockito.anyString()); } + @Test + public void writeBrowserTooOldPage_setContentType() throws IOException { + initMocks(true, true); + handler.writeBrowserTooOldPage(request, response); + + Mockito.verify(response).setContentType( + ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8); + } + @After public void tearDown() { VaadinSession.setCurrent(null);