Commit 392abf6b by Mark Wielaard Committed by Mark Wielaard

System.java (static): Set http.agent system property when not yet set.

       * java/lang/System.java (static): Set http.agent system property when
       not yet set.
       * gnu/java/net/protocol/http/Connection.java (static): Get httpAgent
       from system property inside AccessController.doPrivileged() call.
       (proxyPort): Made package private.
       (proxyInUse): Likewise.
       (proxyHost): Likewise.
       (userAgent): Likewise.

From-SVN: r85078
parent 6d97cb60
2004-07-23 Mark Wielaard <mark@klomp.org> 2004-07-23 Mark Wielaard <mark@klomp.org>
* java/lang/System.java (static): Set http.agent system property when
not yet set.
* gnu/java/net/protocol/http/Connection.java (static): Get httpAgent
from system property inside AccessController.doPrivileged() call.
(proxyPort): Made package private.
(proxyInUse): Likewise.
(proxyHost): Likewise.
(userAgent): Likewise.
2004-07-23 Mark Wielaard <mark@klomp.org>
* gnu/java/net/DefaultContentHandlerFactory.java: New dummy * gnu/java/net/DefaultContentHandlerFactory.java: New dummy
implementation. implementation.
......
/* HttpURLConnection.java -- URLConnection class for HTTP protocol /* HttpURLConnection.java -- URLConnection class for HTTP protocol
Copyright (C) 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc. Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004
Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -52,6 +53,8 @@ import java.net.ProtocolException; ...@@ -52,6 +53,8 @@ import java.net.ProtocolException;
import java.net.Socket; import java.net.Socket;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
...@@ -76,41 +79,45 @@ public final class Connection extends HttpURLConnection ...@@ -76,41 +79,45 @@ public final class Connection extends HttpURLConnection
* The socket we are connected to * The socket we are connected to
*/ */
private Socket socket; private Socket socket;
private static int proxyPort = 80;
private static boolean proxyInUse = false; // Properties depeending on system properties settings
private static String proxyHost = null; static int proxyPort = 80;
static boolean proxyInUse = false;
private static final String userAgent; static String proxyHost = null;
static String userAgent;
static static
{ {
// Recognize some networking properties listed at // Make sure access control for system properties depends only on
// http://java.sun.com/j2se/1.4/docs/guide/net/properties.html. // our class ProtectionDomain, not on any (indirect) callers.
String port = null; AccessController.doPrivileged(new PrivilegedAction() {
proxyHost = System.getProperty("http.proxyHost"); public Object run()
if (proxyHost != null) {
{ // Recognize some networking properties listed at
proxyInUse = true; // http://java.sun.com/j2se/1.4/docs/guide/net/properties.html.
if ((port = System.getProperty("http.proxyPort")) != null) String port = null;
{ proxyHost = System.getProperty("http.proxyHost");
try if (proxyHost != null)
{ {
proxyPort = Integer.parseInt(port); proxyInUse = true;
} if ((port = System.getProperty("http.proxyPort")) != null)
catch (Throwable t) {
{ try
// Nothing. {
} proxyPort = Integer.parseInt(port);
} }
} catch (Throwable t)
{
// Nothing.
}
}
}
userAgent = System.getProperty("http.agent");
userAgent = "gnu-classpath/" return null;
+ System.getProperty("gnu.classpath.version") }
+ " (" });
+ System.getProperty("gnu.classpath.vm.shortname")
+ "/"
+ System.getProperty("java.vm.version")
+ ")";
} }
/** /**
......
/* System.java -- useful methods to interface with the system /* System.java -- useful methods to interface with the system
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -98,6 +99,20 @@ public final class System ...@@ -98,6 +99,20 @@ public final class System
defaultProperties.put("gnu.classpath.vm.shortname", value); defaultProperties.put("gnu.classpath.vm.shortname", value);
} }
// Network properties
if (defaultProperties.get("http.agent") == null)
{
String userAgent
= ("gnu-classpath/"
+ defaultProperties.getProperty("gnu.classpath.version")
+ " ("
+ defaultProperties.getProperty("gnu.classpath.vm.shortname")
+ "/"
+ defaultProperties.getProperty("java.vm.version")
+ ")");
defaultProperties.put("http.agent", userAgent);
}
defaultProperties.put("gnu.cpu.endian", defaultProperties.put("gnu.cpu.endian",
isWordsBigEndian() ? "big" : "little"); isWordsBigEndian() ? "big" : "little");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment