Skip to content

Commit aeb8fa0

Browse files
committed
HtmlImage onerror event is triggerd for 204 responses
1 parent 0cd3c88 commit aeb8fa0

File tree

4 files changed

+376
-23
lines changed

4 files changed

+376
-23
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="4.11.0" date="March xx, 2025" description="Bugfixes">
11+
<action type="fix" dev="rbri">
12+
HtmlImage onerror event is triggerd for 204 responses.
13+
</action>
1114
<action type="fix" dev="rbri">
1215
Fix various event initialization when working with WebSocket's.
1316
</action>

src/main/java/org/htmlunit/html/HtmlImage.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.htmlunit.WebClient;
4242
import org.htmlunit.WebRequest;
4343
import org.htmlunit.WebResponse;
44+
import org.htmlunit.http.HttpStatus;
4445
import org.htmlunit.javascript.AbstractJavaScriptEngine;
4546
import org.htmlunit.javascript.PostponedAction;
4647
import org.htmlunit.javascript.host.dom.Document;
@@ -278,7 +279,9 @@ public void doOnLoad() {
278279
downloadImageIfNeeded();
279280
// if the download was a success
280281
if (imageWebResponse_.isSuccess()) {
281-
loadSuccessful = true; // Trigger the onload handler
282+
if (imageWebResponse_.getStatusCode() != HttpStatus.NO_CONTENT_204) {
283+
loadSuccessful = true; // Trigger the onload handler
284+
}
282285
}
283286
}
284287
catch (final IOException e) {

0 commit comments

Comments
 (0)