50 import java.net.Authenticator.RequestorType; |
50 import java.net.Authenticator.RequestorType; |
51 import java.security.AccessController; |
51 import java.security.AccessController; |
52 import java.security.PrivilegedExceptionAction; |
52 import java.security.PrivilegedExceptionAction; |
53 import java.security.PrivilegedActionException; |
53 import java.security.PrivilegedActionException; |
54 import java.io.*; |
54 import java.io.*; |
55 import java.net.*; |
|
56 import java.util.ArrayList; |
55 import java.util.ArrayList; |
57 import java.util.Collections; |
56 import java.util.Collections; |
58 import java.util.Date; |
57 import java.util.Date; |
59 import java.util.Map; |
58 import java.util.Map; |
60 import java.util.List; |
59 import java.util.List; |
76 import sun.util.logging.PlatformLogger; |
75 import sun.util.logging.PlatformLogger; |
77 import java.text.SimpleDateFormat; |
76 import java.text.SimpleDateFormat; |
78 import java.util.TimeZone; |
77 import java.util.TimeZone; |
79 import java.net.MalformedURLException; |
78 import java.net.MalformedURLException; |
80 import java.nio.ByteBuffer; |
79 import java.nio.ByteBuffer; |
|
80 import java.util.Properties; |
81 import static sun.net.www.protocol.http.AuthScheme.BASIC; |
81 import static sun.net.www.protocol.http.AuthScheme.BASIC; |
82 import static sun.net.www.protocol.http.AuthScheme.DIGEST; |
82 import static sun.net.www.protocol.http.AuthScheme.DIGEST; |
83 import static sun.net.www.protocol.http.AuthScheme.NTLM; |
83 import static sun.net.www.protocol.http.AuthScheme.NTLM; |
84 import static sun.net.www.protocol.http.AuthScheme.NEGOTIATE; |
84 import static sun.net.www.protocol.http.AuthScheme.NEGOTIATE; |
85 import static sun.net.www.protocol.http.AuthScheme.KERBEROS; |
85 import static sun.net.www.protocol.http.AuthScheme.KERBEROS; |
86 import static sun.net.www.protocol.http.AuthScheme.UNKNOWN; |
86 import static sun.net.www.protocol.http.AuthScheme.UNKNOWN; |
|
87 import sun.security.action.GetIntegerAction; |
|
88 import sun.security.action.GetPropertyAction; |
87 |
89 |
88 /** |
90 /** |
89 * A class to represent an HTTP connection to a remote object. |
91 * A class to represent an HTTP connection to a remote object. |
90 */ |
92 */ |
91 |
93 |
203 //"User-Agent", |
205 //"User-Agent", |
204 "Via" |
206 "Via" |
205 }; |
207 }; |
206 |
208 |
207 static { |
209 static { |
208 maxRedirects = java.security.AccessController.doPrivileged( |
210 Properties props = GetPropertyAction.getProperties(); |
209 new sun.security.action.GetIntegerAction( |
211 maxRedirects = GetIntegerAction.getProperty("http.maxRedirects", |
210 "http.maxRedirects", defaultmaxRedirects)).intValue(); |
212 defaultmaxRedirects); |
211 version = java.security.AccessController.doPrivileged( |
213 version = props.getProperty("java.version"); |
212 new sun.security.action.GetPropertyAction("java.version")); |
214 String agent = props.getProperty("http.agent"); |
213 String agent = java.security.AccessController.doPrivileged( |
|
214 new sun.security.action.GetPropertyAction("http.agent")); |
|
215 if (agent == null) { |
215 if (agent == null) { |
216 agent = "Java/"+version; |
216 agent = "Java/"+version; |
217 } else { |
217 } else { |
218 agent = agent + " Java/"+version; |
218 agent = agent + " Java/"+version; |
219 } |
219 } |
220 userAgent = agent; |
220 userAgent = agent; |
221 validateProxy = java.security.AccessController.doPrivileged( |
221 validateProxy = Boolean.parseBoolean( |
222 new sun.security.action.GetBooleanAction( |
222 props.getProperty("http.auth.digest.validateProxy")); |
223 "http.auth.digest.validateProxy")).booleanValue(); |
223 validateServer = Boolean.parseBoolean( |
224 validateServer = java.security.AccessController.doPrivileged( |
224 props.getProperty("http.auth.digest.validateServer")); |
225 new sun.security.action.GetBooleanAction( |
225 |
226 "http.auth.digest.validateServer")).booleanValue(); |
226 enableESBuffer = Boolean.parseBoolean( |
227 |
227 props.getProperty("sun.net.http.errorstream.enableBuffering")); |
228 enableESBuffer = java.security.AccessController.doPrivileged( |
228 timeout4ESBuffer = GetIntegerAction |
229 new sun.security.action.GetBooleanAction( |
229 .getProperty("sun.net.http.errorstream.timeout", 300); |
230 "sun.net.http.errorstream.enableBuffering")).booleanValue(); |
|
231 timeout4ESBuffer = java.security.AccessController.doPrivileged( |
|
232 new sun.security.action.GetIntegerAction( |
|
233 "sun.net.http.errorstream.timeout", 300)).intValue(); |
|
234 if (timeout4ESBuffer <= 0) { |
230 if (timeout4ESBuffer <= 0) { |
235 timeout4ESBuffer = 300; // use the default |
231 timeout4ESBuffer = 300; // use the default |
236 } |
232 } |
237 |
233 |
238 bufSize4ES = java.security.AccessController.doPrivileged( |
234 bufSize4ES = GetIntegerAction |
239 new sun.security.action.GetIntegerAction( |
235 .getProperty("sun.net.http.errorstream.bufferSize", 4096); |
240 "sun.net.http.errorstream.bufferSize", 4096)).intValue(); |
|
241 if (bufSize4ES <= 0) { |
236 if (bufSize4ES <= 0) { |
242 bufSize4ES = 4096; // use the default |
237 bufSize4ES = 4096; // use the default |
243 } |
238 } |
244 |
239 |
245 allowRestrictedHeaders = java.security.AccessController.doPrivileged( |
240 allowRestrictedHeaders = Boolean.parseBoolean( |
246 new sun.security.action.GetBooleanAction( |
241 props.getProperty("sun.net.http.allowRestrictedHeaders")); |
247 "sun.net.http.allowRestrictedHeaders")).booleanValue(); |
|
248 if (!allowRestrictedHeaders) { |
242 if (!allowRestrictedHeaders) { |
249 restrictedHeaderSet = new HashSet<>(restrictedHeaders.length); |
243 restrictedHeaderSet = new HashSet<>(restrictedHeaders.length); |
250 for (int i=0; i < restrictedHeaders.length; i++) { |
244 for (int i=0; i < restrictedHeaders.length; i++) { |
251 restrictedHeaderSet.add(restrictedHeaders[i].toLowerCase()); |
245 restrictedHeaderSet.add(restrictedHeaders[i].toLowerCase()); |
252 } |
246 } |