Addresses #8775 for version 8.1+tags/8.1.0.alpha7
@@ -363,7 +363,8 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler { | |||
private void writeBootstrapPage(VaadinResponse response, String html) | |||
throws IOException { | |||
response.setContentType("text/html"); | |||
response.setContentType( | |||
ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8); | |||
try (BufferedWriter writer = new BufferedWriter( | |||
new OutputStreamWriter(response.getOutputStream(), "UTF-8"))) { | |||
writer.append(html); | |||
@@ -383,8 +384,8 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler { | |||
document.child(0).before(doctype); | |||
Element head = document.head(); | |||
head.appendElement("meta").attr("http-equiv", "Content-Type") | |||
.attr("content", "text/html; charset=utf-8"); | |||
head.appendElement("meta").attr("http-equiv", "Content-Type").attr( | |||
"content", ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8); | |||
/* | |||
* Enable Chrome Frame in all versions of IE if installed. |
@@ -55,6 +55,7 @@ import com.vaadin.annotations.VaadinServletConfiguration; | |||
import com.vaadin.annotations.VaadinServletConfiguration.InitParameterName; | |||
import com.vaadin.sass.internal.ScssStylesheet; | |||
import com.vaadin.server.communication.ServletUIInitHandler; | |||
import com.vaadin.shared.ApplicationConstants; | |||
import com.vaadin.shared.JsonConstants; | |||
import com.vaadin.shared.Version; | |||
import com.vaadin.ui.UI; | |||
@@ -585,7 +586,7 @@ public class VaadinServlet extends HttpServlet implements Constants { | |||
output += "</a>"; | |||
} | |||
getService().writeStringResponse(response, | |||
"text/html; charset=UTF-8", output); | |||
ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8, output); | |||
} | |||
} | |||
@@ -36,6 +36,7 @@ import com.vaadin.server.UploadException; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.server.VaadinResponse; | |||
import com.vaadin.server.VaadinSession; | |||
import com.vaadin.shared.ApplicationConstants; | |||
import com.vaadin.ui.UI; | |||
import com.vaadin.ui.Upload.FailedEvent; | |||
@@ -675,7 +676,8 @@ public class FileUploadHandler implements RequestHandler { | |||
*/ | |||
protected void sendUploadResponse(VaadinRequest request, | |||
VaadinResponse response) throws IOException { | |||
response.setContentType("text/html"); | |||
response.setContentType( | |||
ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8); | |||
try (OutputStream out = response.getOutputStream()) { | |||
final PrintWriter outWriter = new PrintWriter( | |||
new BufferedWriter(new OutputStreamWriter(out, "UTF-8"))); |
@@ -25,6 +25,7 @@ import java.util.HashMap; | |||
import java.util.Map; | |||
import com.vaadin.server.StreamResource; | |||
import com.vaadin.shared.ApplicationConstants; | |||
import com.vaadin.shared.Registration; | |||
import com.vaadin.shared.ui.loginform.LoginFormConstants; | |||
import com.vaadin.shared.ui.loginform.LoginFormRpc; | |||
@@ -307,7 +308,7 @@ public class LoginForm extends AbstractSingleComponentContainer { | |||
StreamResource resource = new StreamResource(new LoginStreamSource(), | |||
LoginFormConstants.LOGIN_RESOURCE_NAME); | |||
resource.setMIMEType("text/html; charset=utf-8"); | |||
resource.setMIMEType(ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8); | |||
resource.setCacheTime(-1); | |||
setResource(LoginFormConstants.LOGIN_RESOURCE_NAME, resource); | |||
@@ -179,4 +179,9 @@ public class ApplicationConstants implements Serializable { | |||
*/ | |||
public static final String WIDGETSET_VERSION_ID = "wsver"; | |||
/** | |||
* Content type to use for text/html responses (should always be UTF-8). | |||
*/ | |||
public static final String CONTENT_TYPE_TEXT_HTML_UTF_8 = "text/html; charset=utf-8"; | |||
} |