FULL PRODUCT VERSION :
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
We have server which returns two setCookies string in the URL response.
if we have java fx webview is initialized, then HttpUrlConnection.getHeaders not returning all cookies headers. we can see that information in the delagteConnection in the connection object. But getHeaders is not returning all the cookies
if we run the same code without the webview, it is returning perfectly fine
Also, if we use org.apache.commons.client.default client irrespective of the webview, it returns the complete cookies
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Please run the below Java code in the debug environement and please ensure that webview gets initialized before getHeaders called.
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.SocketAddress;
import java.net.URL;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.List;
import java.util.Map;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import com.sap.hilo.util.base64.Base64Coder;
import com.sap.hilo.util.encoding.StringHelper;
public class TestHTTPConnection
{
// private String _url = //have an url which returns two Set-Cookies field //in the response.
public HttpURLConnection createHttpConnection() throws Exception
{
URL url = new URL(_url);
boolean isHttps = true;
SSLContext ctx = null;
HttpURLConnection conn = null;
{
SocketAddress address = new InetSocketAddress("proxy", 8080);
Proxy proxy = new Proxy(Proxy.Type.HTTP, address);
conn = (HttpURLConnection) url.openConnection(proxy);
}
if (isHttps)
{
HttpsURLConnection sslConn = (HttpsURLConnection) conn;
if (ctx != null)
{
sslConn.setSSLSocketFactory(ctx.getSocketFactory());
}
sslConn.setHostnameVerifier(new HostnameVerifier()
{
@Override
public boolean verify(String paramString, SSLSession paramSSLSession)
{
return true;
}
});
}
conn.setDoInput(true);
return conn;
}
public InputStream getResponseContent(HttpURLConnection con)
{
try
{
return (InputStream) con.getContent();
}
catch (IOException ioEx)
{
return null;
}
}
public Map<String, List<String>> getResponseHeaders(HttpURLConnection con)
{
return con.getHeaderFields();
}
public static void main(String[] args)
{
new JFXPanel();
Platform.runLater(new Runnable()
{
@Override
public void run()
{
loadWebView();
}
});
TestHTTPConnection connectionClass = new TestHTTPConnection();
try
{
HttpURLConnection con = connectionClass.createHttpConnection();
// String credentials = "prasanna.bhat.mavinakuli@sap.com" + ":" + "Password@1"; //$NON-NLS-1$
String credentials = "prasanna.mavinakuli@gmail.com" + ":" + "Password1";
String encodedCredentials = Base64Coder.encode(credentials.getBytes("UTF-8")); //$NON-NLS-1$
String authHeader = "Basic " + encodedCredentials;
con.setRequestProperty("Authorization", authHeader);
con.setRequestMethod("GET");
InputStream is = connectionClass.getResponseContent(con);
System.out.println("Headers!"+connectionClass.getResponseHeaders(con).toString());
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private static void loadWebView()
{
final WebView browser = new WebView();
final WebEngine webEngine = browser.getEngine();
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expect the same all cookies sent by server irrespective of webview is there or not
ACTUAL -
I don't see all cookies set by server when we have webview is initialized.
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
we don't have any workaround for this problem and it stops us from delivering our features
SUPPORT :
YES
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
We have server which returns two setCookies string in the URL response.
if we have java fx webview is initialized, then HttpUrlConnection.getHeaders not returning all cookies headers. we can see that information in the delagteConnection in the connection object. But getHeaders is not returning all the cookies
if we run the same code without the webview, it is returning perfectly fine
Also, if we use org.apache.commons.client.default client irrespective of the webview, it returns the complete cookies
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Please run the below Java code in the debug environement and please ensure that webview gets initialized before getHeaders called.
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.SocketAddress;
import java.net.URL;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.List;
import java.util.Map;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import com.sap.hilo.util.base64.Base64Coder;
import com.sap.hilo.util.encoding.StringHelper;
public class TestHTTPConnection
{
// private String _url = //have an url which returns two Set-Cookies field //in the response.
public HttpURLConnection createHttpConnection() throws Exception
{
URL url = new URL(_url);
boolean isHttps = true;
SSLContext ctx = null;
HttpURLConnection conn = null;
{
SocketAddress address = new InetSocketAddress("proxy", 8080);
Proxy proxy = new Proxy(Proxy.Type.HTTP, address);
conn = (HttpURLConnection) url.openConnection(proxy);
}
if (isHttps)
{
HttpsURLConnection sslConn = (HttpsURLConnection) conn;
if (ctx != null)
{
sslConn.setSSLSocketFactory(ctx.getSocketFactory());
}
sslConn.setHostnameVerifier(new HostnameVerifier()
{
@Override
public boolean verify(String paramString, SSLSession paramSSLSession)
{
return true;
}
});
}
conn.setDoInput(true);
return conn;
}
public InputStream getResponseContent(HttpURLConnection con)
{
try
{
return (InputStream) con.getContent();
}
catch (IOException ioEx)
{
return null;
}
}
public Map<String, List<String>> getResponseHeaders(HttpURLConnection con)
{
return con.getHeaderFields();
}
public static void main(String[] args)
{
new JFXPanel();
Platform.runLater(new Runnable()
{
@Override
public void run()
{
loadWebView();
}
});
TestHTTPConnection connectionClass = new TestHTTPConnection();
try
{
HttpURLConnection con = connectionClass.createHttpConnection();
// String credentials = "prasanna.bhat.mavinakuli@sap.com" + ":" + "Password@1"; //$NON-NLS-1$
String credentials = "prasanna.mavinakuli@gmail.com" + ":" + "Password1";
String encodedCredentials = Base64Coder.encode(credentials.getBytes("UTF-8")); //$NON-NLS-1$
String authHeader = "Basic " + encodedCredentials;
con.setRequestProperty("Authorization", authHeader);
con.setRequestMethod("GET");
InputStream is = connectionClass.getResponseContent(con);
System.out.println("Headers!"+connectionClass.getResponseHeaders(con).toString());
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private static void loadWebView()
{
final WebView browser = new WebView();
final WebEngine webEngine = browser.getEngine();
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expect the same all cookies sent by server irrespective of webview is there or not
ACTUAL -
I don't see all cookies set by server when we have webview is initialized.
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
we don't have any workaround for this problem and it stops us from delivering our features
SUPPORT :
YES