< prev index next >

src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java

Print this page
rev 14210 : 8154231: Simplify access to System properties from JDK code
Reviewed-by: rriggs

*** 50,60 **** import java.net.Authenticator.RequestorType; import java.security.AccessController; import java.security.PrivilegedExceptionAction; import java.security.PrivilegedActionException; import java.io.*; - import java.net.*; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.Map; import java.util.List; --- 50,59 ----
*** 76,91 **** --- 75,93 ---- import sun.util.logging.PlatformLogger; import java.text.SimpleDateFormat; import java.util.TimeZone; import java.net.MalformedURLException; import java.nio.ByteBuffer; + import java.util.Properties; import static sun.net.www.protocol.http.AuthScheme.BASIC; import static sun.net.www.protocol.http.AuthScheme.DIGEST; import static sun.net.www.protocol.http.AuthScheme.NTLM; import static sun.net.www.protocol.http.AuthScheme.NEGOTIATE; import static sun.net.www.protocol.http.AuthScheme.KERBEROS; import static sun.net.www.protocol.http.AuthScheme.UNKNOWN; + import sun.security.action.GetIntegerAction; + import sun.security.action.GetPropertyAction; /** * A class to represent an HTTP connection to a remote object. */
*** 203,252 **** //"User-Agent", "Via" }; static { ! maxRedirects = java.security.AccessController.doPrivileged( ! new sun.security.action.GetIntegerAction( ! "http.maxRedirects", defaultmaxRedirects)).intValue(); ! version = java.security.AccessController.doPrivileged( ! new sun.security.action.GetPropertyAction("java.version")); ! String agent = java.security.AccessController.doPrivileged( ! new sun.security.action.GetPropertyAction("http.agent")); if (agent == null) { agent = "Java/"+version; } else { agent = agent + " Java/"+version; } userAgent = agent; ! validateProxy = java.security.AccessController.doPrivileged( ! new sun.security.action.GetBooleanAction( ! "http.auth.digest.validateProxy")).booleanValue(); ! validateServer = java.security.AccessController.doPrivileged( ! new sun.security.action.GetBooleanAction( ! "http.auth.digest.validateServer")).booleanValue(); ! ! enableESBuffer = java.security.AccessController.doPrivileged( ! new sun.security.action.GetBooleanAction( ! "sun.net.http.errorstream.enableBuffering")).booleanValue(); ! timeout4ESBuffer = java.security.AccessController.doPrivileged( ! new sun.security.action.GetIntegerAction( ! "sun.net.http.errorstream.timeout", 300)).intValue(); if (timeout4ESBuffer <= 0) { timeout4ESBuffer = 300; // use the default } ! bufSize4ES = java.security.AccessController.doPrivileged( ! new sun.security.action.GetIntegerAction( ! "sun.net.http.errorstream.bufferSize", 4096)).intValue(); if (bufSize4ES <= 0) { bufSize4ES = 4096; // use the default } ! allowRestrictedHeaders = java.security.AccessController.doPrivileged( ! new sun.security.action.GetBooleanAction( ! "sun.net.http.allowRestrictedHeaders")).booleanValue(); if (!allowRestrictedHeaders) { restrictedHeaderSet = new HashSet<>(restrictedHeaders.length); for (int i=0; i < restrictedHeaders.length; i++) { restrictedHeaderSet.add(restrictedHeaders[i].toLowerCase()); } --- 205,246 ---- //"User-Agent", "Via" }; static { ! Properties props = GetPropertyAction.getProperties(); ! maxRedirects = GetIntegerAction.getProperty("http.maxRedirects", ! defaultmaxRedirects); ! version = props.getProperty("java.version"); ! String agent = props.getProperty("http.agent"); if (agent == null) { agent = "Java/"+version; } else { agent = agent + " Java/"+version; } userAgent = agent; ! validateProxy = Boolean.parseBoolean( ! props.getProperty("http.auth.digest.validateProxy")); ! validateServer = Boolean.parseBoolean( ! props.getProperty("http.auth.digest.validateServer")); ! ! enableESBuffer = Boolean.parseBoolean( ! props.getProperty("sun.net.http.errorstream.enableBuffering")); ! timeout4ESBuffer = GetIntegerAction ! .getProperty("sun.net.http.errorstream.timeout", 300); if (timeout4ESBuffer <= 0) { timeout4ESBuffer = 300; // use the default } ! bufSize4ES = GetIntegerAction ! .getProperty("sun.net.http.errorstream.bufferSize", 4096); if (bufSize4ES <= 0) { bufSize4ES = 4096; // use the default } ! allowRestrictedHeaders = Boolean.parseBoolean( ! props.getProperty("sun.net.http.allowRestrictedHeaders")); if (!allowRestrictedHeaders) { restrictedHeaderSet = new HashSet<>(restrictedHeaders.length); for (int i=0; i < restrictedHeaders.length; i++) { restrictedHeaderSet.add(restrictedHeaders[i].toLowerCase()); }
< prev index next >