-
Bug
-
Resolution: Fixed
-
P4
-
jfx12, 8u192
-
x86_64
-
windows_10
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8213938 | openjdk8u212 | Samir Hadzic | P4 | Resolved | Fixed | |
JDK-8215742 | 8u212 | Samir Hadzic | P4 | Resolved | Fixed | b01 |
JDK-8216015 | 8u211 | Samir Hadzic | P4 | Resolved | Fixed | b01 |
JDK-8222040 | jfx11.0.3 | Samir Hadzic | P4 | Closed | Fixed |
If you try to load an URL into the WebView where the response does not specify the content-type, the Loader state switch to "cancelled".
STEPS TO REPRODUCE (a bit technical because we want to remove headers):
- Download Fiddler here : https://www.telerik.com/download/fiddler
- Launch it, then click on "Rules" -> "Customize rules"
- On the Fiddler script editor, scroll to the function "OnBeforeResponse" and modify it like that :
static function OnBeforeResponse(oSession: Session) {
if (m_Hide304s && oSession.responseCode == 304) {
oSession["ui-hide"] = "true";
}
if (oSession.uriContains("google") && oSession.responseCode == 200) {
oSession["ui-color"] = "red";
oSession.oResponse.headers.Remove("Content-Type");
}
}
- Then run the class given in attachment
EXPECTED RESULT:
The WebView should load the google webPage and display it.
ACTUAL RESULT:
The WebView loader switch to "Cancelled" state.
EXPLANATION:
If we look at the RFC : https://tools.ietf.org/html/rfc7231#section-3.1.1.5 , we can see that the Content-type is not mandatory. Browser do display properly a webPage without Content-Type.
If we debug, we can see that in com.sun.webkit.network.URLLoader, we enter the method "notifyDidReceiveResponse", then call the native method "twkDidReceiveResponse".
I do not have access to the native code, but after that, the WebView is notified to switch to Cancelled mode because the response is detected as incorrect.
WORK-AROUND:
Currently, it's a bit difficult. A solution consists of providing a custom URLStreamHandlerFactory in URL class. Then we can provide a custom Handler that would override "openConnection" in order to retrieve the URLConnection, wrap it and delegates all methods except from "getContentType" in order to return a default content-type when null.
STEPS TO REPRODUCE (a bit technical because we want to remove headers):
- Download Fiddler here : https://www.telerik.com/download/fiddler
- Launch it, then click on "Rules" -> "Customize rules"
- On the Fiddler script editor, scroll to the function "OnBeforeResponse" and modify it like that :
static function OnBeforeResponse(oSession: Session) {
if (m_Hide304s && oSession.responseCode == 304) {
oSession["ui-hide"] = "true";
}
if (oSession.uriContains("google") && oSession.responseCode == 200) {
oSession["ui-color"] = "red";
oSession.oResponse.headers.Remove("Content-Type");
}
}
- Then run the class given in attachment
EXPECTED RESULT:
The WebView should load the google webPage and display it.
ACTUAL RESULT:
The WebView loader switch to "Cancelled" state.
EXPLANATION:
If we look at the RFC : https://tools.ietf.org/html/rfc7231#section-3.1.1.5 , we can see that the Content-type is not mandatory. Browser do display properly a webPage without Content-Type.
If we debug, we can see that in com.sun.webkit.network.URLLoader, we enter the method "notifyDidReceiveResponse", then call the native method "twkDidReceiveResponse".
I do not have access to the native code, but after that, the WebView is notified to switch to Cancelled mode because the response is detected as incorrect.
WORK-AROUND:
Currently, it's a bit difficult. A solution consists of providing a custom URLStreamHandlerFactory in URL class. Then we can provide a custom Handler that would override "openConnection" in order to retrieve the URLConnection, wrap it and delegates all methods except from "getContentType" in order to return a default content-type when null.
- backported by
-
JDK-8213938 WebView does not handle HTTP response without ContentType
- Resolved
-
JDK-8215742 WebView does not handle HTTP response without ContentType
- Resolved
-
JDK-8216015 WebView does not handle HTTP response without ContentType
- Resolved
-
JDK-8222040 WebView does not handle HTTP response without ContentType
- Closed
- relates to
-
JDK-8113134 testLoadUrlWithEncodedSpaces, testLoadUrlWithUnencodedSpaces fail if Skype is running
- Resolved
- links to
(1 links to)