public VisitStatus visit(Gadget gadget, Node node) throws RewritingException { if (node.getNodeType() == Node.ELEMENT_NODE && META.equalsIgnoreCase(node.getNodeName())) { Element elem = (Element) node; String httpEquip = elem.getAttribute(HTTP_EQUIV); String content = elem.getAttribute(CONTENT); if (httpEquip != null && content != null && CONTENT_TYPE.equalsIgnoreCase(httpEquip)) { elem.setAttribute(CONTENT, UriUtils.getContentTypeWithoutCharset(content)); return VisitStatus.MODIFY; } } return VisitStatus.BYPASS; }
public VisitStatus visit(Gadget gadget, Node node) throws RewritingException { if (node.getNodeType() == Node.ELEMENT_NODE && META.equalsIgnoreCase(node.getNodeName())) { Element elem = (Element) node; String httpEquip = elem.getAttribute(HTTP_EQUIV); String content = elem.getAttribute(CONTENT); if (httpEquip != null && content != null && CONTENT_TYPE.equalsIgnoreCase(httpEquip)) { elem.setAttribute(CONTENT, UriUtils.getContentTypeWithoutCharset(content)); return VisitStatus.MODIFY; } } return VisitStatus.BYPASS; }
public VisitStatus visit(Gadget gadget, Node node) throws RewritingException { if (node.getNodeType() == Node.ELEMENT_NODE && META.equalsIgnoreCase(node.getNodeName())) { Element elem = (Element) node; String httpEquip = elem.getAttribute(HTTP_EQUIV); String content = elem.getAttribute(CONTENT); if (httpEquip != null && content != null && CONTENT_TYPE.equalsIgnoreCase(httpEquip)) { elem.setAttribute(CONTENT, UriUtils.getContentTypeWithoutCharset(content)); return VisitStatus.MODIFY; } } return VisitStatus.BYPASS; }
@Test public void testGetContentTypeWithoutCharset() { assertEquals("text/html", UriUtils.getContentTypeWithoutCharset("text/html")); assertEquals("text/html;", UriUtils.getContentTypeWithoutCharset("text/html;")); assertEquals("text/html", UriUtils.getContentTypeWithoutCharset("text/html; charset=hello")); assertEquals("text/html; hello=world", UriUtils.getContentTypeWithoutCharset("text/html; charset=hello; hello=world")); assertEquals("text/html; pharset=hello; hello=world", UriUtils.getContentTypeWithoutCharset("text/html; pharset=hello; hello=world")); assertEquals("text/html; charsett=utf; hello=world", UriUtils.getContentTypeWithoutCharset("text/html; charsett=utf; ; hello=world")); } }
@Test public void testGetContentTypeWithoutCharset() { assertEquals("text/html", UriUtils.getContentTypeWithoutCharset("text/html")); assertEquals("text/html;", UriUtils.getContentTypeWithoutCharset("text/html;")); assertEquals("text/html", UriUtils.getContentTypeWithoutCharset("text/html; charset=hello")); assertEquals("text/html; hello=world", UriUtils.getContentTypeWithoutCharset("text/html; charset=hello; hello=world")); assertEquals("text/html; pharset=hello; hello=world", UriUtils.getContentTypeWithoutCharset("text/html; pharset=hello; hello=world")); assertEquals("text/html; charsett=utf; hello=world", UriUtils.getContentTypeWithoutCharset("text/html; charsett=utf; ; hello=world")); } }
@Test public void testGetContentTypeWithoutCharset() { assertEquals("text/html", UriUtils.getContentTypeWithoutCharset("text/html")); assertEquals("text/html;", UriUtils.getContentTypeWithoutCharset("text/html;")); assertEquals("text/html", UriUtils.getContentTypeWithoutCharset("text/html; charset=hello")); assertEquals("text/html; hello=world", UriUtils.getContentTypeWithoutCharset("text/html; charset=hello; hello=world")); assertEquals("text/html; pharset=hello; hello=world", UriUtils.getContentTypeWithoutCharset("text/html; pharset=hello; hello=world")); assertEquals("text/html; charsett=utf; hello=world", UriUtils.getContentTypeWithoutCharset("text/html; charsett=utf; ; hello=world")); } }