Skip to content

Commit 4d43a84

Browse files
committed
document last changes
1 parent 422fe17 commit 4d43a84

File tree

2 files changed

+59
-4
lines changed

2 files changed

+59
-4
lines changed

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
<body>
1010
<release version="5.0.0" date="April 01, 2026" description="jdk17, Bugfixes">
11+
<action type="fix" dev="Lai Quang Duong">
12+
Force content sniffing for '*/*' content type to be in sync with the browsers.
13+
</action>
1114
<action type="add" dev="Lai Quang Duong">
1215
SubtleCrypto: digest() - SHA-1, SHA-256, SHA-384, SHA-512.
1316
</action>

src/test/java/org/htmlunit/DefaultPageCreatorTest.java

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,19 +382,19 @@ protected void doGet(final HttpServletRequest request, final HttpServletResponse
382382
* @throws Exception if the test fails
383383
*/
384384
@Test
385-
public void wildcardContentType() throws Exception {
385+
public void wildcardContentTypeHtml() throws Exception {
386386
final Map<String, Class<? extends Servlet>> servlets = new HashMap<>();
387-
servlets.put("/test", WildcardContentTypeServlet.class);
387+
servlets.put("/test", WildcardContentTypeHtmlServlet.class);
388388
startWebServer("./", servlets);
389389

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

394394
/**
395-
* Servlet for {@link #wildcardContentType()}.
395+
* Servlet for {@link #wildcardContentTypeHtml()}.
396396
*/
397-
public static class WildcardContentTypeServlet extends HttpServlet {
397+
public static class WildcardContentTypeHtmlServlet extends HttpServlet {
398398
/** {@inheritDoc} */
399399
@Override
400400
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
@@ -404,6 +404,58 @@ protected void doGet(final HttpServletRequest request, final HttpServletResponse
404404
}
405405
}
406406

407+
/**
408+
* @throws Exception if the test fails
409+
*/
410+
@Test
411+
public void wildcardContentTypeXml() throws Exception {
412+
final Map<String, Class<? extends Servlet>> servlets = new HashMap<>();
413+
servlets.put("/test", WildcardContentTypeXmlServlet.class);
414+
startWebServer("./", servlets);
415+
416+
final WebClient client = getWebClient();
417+
assertTrue(client.getPage(URL_FIRST + "test") instanceof XmlPage);
418+
}
419+
420+
/**
421+
* Servlet for {@link #wildcardContentTypeXml()}.
422+
*/
423+
public static class WildcardContentTypeXmlServlet extends HttpServlet {
424+
/** {@inheritDoc} */
425+
@Override
426+
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
427+
response.setContentType("*/*");
428+
final Writer writer = response.getWriter();
429+
writer.write("<?xml version=\"1.0\" encoding=\"utf-8\" ?><root>Hello World</root>");
430+
}
431+
}
432+
433+
/**
434+
* @throws Exception if the test fails
435+
*/
436+
@Test
437+
public void wildcardContentTypeBom() throws Exception {
438+
final Map<String, Class<? extends Servlet>> servlets = new HashMap<>();
439+
servlets.put("/test", WildcardContentTypeBomServlet.class);
440+
startWebServer("./", servlets);
441+
442+
final WebClient client = getWebClient();
443+
assertTrue(client.getPage(URL_FIRST + "test") instanceof TextPage);
444+
}
445+
446+
/**
447+
* Servlet for {@link #wildcardContentTypeBom()}.
448+
*/
449+
public static class WildcardContentTypeBomServlet extends HttpServlet {
450+
/** {@inheritDoc} */
451+
@Override
452+
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
453+
response.setContentType("*/*");
454+
final Writer writer = response.getWriter();
455+
writer.write("\u00ef\u00bb\u00bf<html><head></head><body></body></html>");
456+
}
457+
}
458+
407459
/**
408460
* @throws Exception if the test fails
409461
*/

0 commit comments

Comments
 (0)