Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/org/htmlunit/DefaultPageCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public static PageType determinePageType(final String contentType) {
*/
public static PageType determinePageType(final WebResponse webResponse) throws IOException {
final String contentType = webResponse.getContentType();
if (!StringUtils.isEmptyOrNull(contentType)) {
if (!StringUtils.isEmptyOrNull(contentType) && !"*/*".equals(contentType)) {
return determinePageType(contentType);
}

Expand Down
27 changes: 27 additions & 0 deletions src/test/java/org/htmlunit/DefaultPageCreatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* @author Marc Guillemot
* @author Ahmed Ashour
* @author Ronald Brill
* @author Lai Quang Duong
*/
public class DefaultPageCreatorTest extends WebServerTestCase {

Expand Down Expand Up @@ -377,6 +378,32 @@ protected void doGet(final HttpServletRequest request, final HttpServletResponse
}
}

/**
* @throws Exception if the test fails
*/
@Test
public void wildcardContentType() throws Exception {
final Map<String, Class<? extends Servlet>> servlets = new HashMap<>();
servlets.put("/test", WildcardContentTypeServlet.class);
startWebServer("./", servlets);

final WebClient client = getWebClient();
assertTrue(client.getPage(URL_FIRST + "test") instanceof HtmlPage);
}

/**
* Servlet for {@link #wildcardContentType()}.
*/
public static class WildcardContentTypeServlet extends HttpServlet {
/** {@inheritDoc} */
@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
response.setContentType("*/*");
final Writer writer = response.getWriter();
writer.write("<html><head></head><body>Hello World</body></html>");
}
}

/**
* @throws Exception if the test fails
*/
Expand Down
Loading