[kaffe] CVS kaffe (robilad): Resynced with GNU Classpath: HTTP connection fixes
Kaffe CVS
cvs-commits at kaffe.org
Wed Jan 12 23:19:56 PST 2005
PatchSet 5844
Date: 2005/01/13 07:15:01
Author: robilad
Branch: HEAD
Tag: (none)
Log:
Resynced with GNU Classpath: HTTP connection fixes
2005-01-13 Dalibor Topic <robilad at kaffe.org>
Resynced with GNU Classpath.
2005-01-11 Chris Burdess <dog at gnu.org>
* gnu/java/net/protocol/http/HTTPConnection.java: Use correct form of
Host header when using a non-default port number.
2005-01-11 Chris Burdess <dog at gnu.org>
* javax/net/ssl/HttpsURLConnection.java: Do not request SSLv3
provider during class initialization.
Members:
ChangeLog:1.3388->1.3389
libraries/javalib/gnu/java/net/protocol/http/HTTPConnection.java:1.3->1.4
libraries/javalib/javax/net/ssl/HttpsURLConnection.java:1.4->1.5
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3388 kaffe/ChangeLog:1.3389
--- kaffe/ChangeLog:1.3388 Thu Jan 13 07:04:16 2005
+++ kaffe/ChangeLog Thu Jan 13 07:15:01 2005
@@ -1,6 +1,20 @@
2005-01-13 Dalibor Topic <robilad at kaffe.org>
Resynced with GNU Classpath.
+
+ 2005-01-11 Chris Burdess <dog at gnu.org>
+
+ * gnu/java/net/protocol/http/HTTPConnection.java: Use correct form of
+ Host header when using a non-default port number.
+
+ 2005-01-11 Chris Burdess <dog at gnu.org>
+
+ * javax/net/ssl/HttpsURLConnection.java: Do not request SSLv3
+ provider during class initialization.
+
+2005-01-13 Dalibor Topic <robilad at kaffe.org>
+
+ Resynced with GNU Classpath.
2005-01-11 Michael Koch <konqueror at gmx.de>
Index: kaffe/libraries/javalib/gnu/java/net/protocol/http/HTTPConnection.java
diff -u kaffe/libraries/javalib/gnu/java/net/protocol/http/HTTPConnection.java:1.3 kaffe/libraries/javalib/gnu/java/net/protocol/http/HTTPConnection.java:1.4
--- kaffe/libraries/javalib/gnu/java/net/protocol/http/HTTPConnection.java:1.3 Sat Jan 8 21:54:52 2005
+++ kaffe/libraries/javalib/gnu/java/net/protocol/http/HTTPConnection.java Thu Jan 13 07:15:04 2005
@@ -369,7 +369,15 @@
path = "/";
}
Request ret = new Request(this, method, path);
- ret.setHeader("Host", hostname);
+ if ((secure && port != HTTPS_PORT) ||
+ (!secure && port != HTTP_PORT))
+ {
+ ret.setHeader("Host", hostname + ":" + port);
+ }
+ else
+ {
+ ret.setHeader("Host", hostname);
+ }
ret.setHeader("User-Agent", userAgent);
ret.setHeader("Connection", "keep-alive");
ret.setHeader("Accept-Encoding",
Index: kaffe/libraries/javalib/javax/net/ssl/HttpsURLConnection.java
diff -u kaffe/libraries/javalib/javax/net/ssl/HttpsURLConnection.java:1.4 kaffe/libraries/javalib/javax/net/ssl/HttpsURLConnection.java:1.5
--- kaffe/libraries/javalib/javax/net/ssl/HttpsURLConnection.java:1.4 Tue Sep 21 13:08:17 2004
+++ kaffe/libraries/javalib/javax/net/ssl/HttpsURLConnection.java Thu Jan 13 07:15:04 2005
@@ -59,10 +59,18 @@
// Fields.
// ------------------------------------------------------------------
- /** The default verifier. */
+ /**
+ * The default verifier.
+ * This is lazily initialized as required.
+ * @see #getDefaultHostnameVerifier
+ */
private static HostnameVerifier defaultVerifier;
- /** The default factory. */
+ /**
+ * The default factory.
+ * This is lazily initialized as required.
+ * @see #getDefaultSSLSocketFactory
+ */
private static SSLSocketFactory defaultFactory;
/**
@@ -75,21 +83,6 @@
*/
private SSLSocketFactory factory;
- // Static initializer.
- // ------------------------------------------------------------------
-
- static {
- defaultVerifier = new TrivialHostnameVerifier();
- try
- {
- defaultFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- }
- }
-
// Constructor.
// ------------------------------------------------------------------
@@ -102,8 +95,6 @@
protected HttpsURLConnection(URL url) throws IOException
{
super(url);
- hostnameVerifier = defaultVerifier;
- factory = defaultFactory;
}
// Class methods.
@@ -112,11 +103,17 @@
/**
* Returns the default hostname verifier used in all new
* connections.
+ * If the default verifier has not been set, a new default one will be
+ * provided by this method.
*
* @return The default hostname verifier.
*/
- public static HostnameVerifier getDefaultHostnameVerifier()
+ public static synchronized HostnameVerifier getDefaultHostnameVerifier()
{
+ if (defaultVerifier == null)
+ {
+ defaultVerifier = new TrivialHostnameVerifier();
+ }
return defaultVerifier;
}
@@ -137,17 +134,33 @@
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkPermission(new SSLPermission("setHostnameVerifier"));
- defaultVerifier = newDefault;
+ synchronized (HttpsURLConnection.class)
+ {
+ defaultVerifier = newDefault;
+ }
}
/**
* Returns the default SSL socket factory used in all new
* connections.
+ * If the default SSL socket factory has not been set, a new default one
+ * will be provided by this method.
*
* @return The default SSL socket factory.
*/
- public static SSLSocketFactory getDefaultSSLSocketFactory()
+ public static synchronized SSLSocketFactory getDefaultSSLSocketFactory()
{
+ if (defaultFactory == null)
+ {
+ try
+ {
+ defaultFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ }
+ }
return defaultFactory;
}
@@ -168,7 +181,10 @@
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkSetFactory();
- defaultFactory = newDefault;
+ synchronized (HttpsURLConnection.class)
+ {
+ defaultFactory = newDefault;
+ }
}
// Instance methods.
@@ -181,6 +197,10 @@
*/
public HostnameVerifier getHostnameVerifier()
{
+ if (hostnameVerifier == null)
+ {
+ hostnameVerifier = getDefaultHostnameVerifier();
+ }
return hostnameVerifier;
}
@@ -205,6 +225,10 @@
*/
public SSLSocketFactory getSSLSocketFactory()
{
+ if (factory == null)
+ {
+ factory = getDefaultSSLSocketFactory();
+ }
return factory;
}
More information about the kaffe
mailing list