Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/net/httpserver/ServerConfig.java
38918 views
1
/*
2
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package sun.net.httpserver;
27
28
import java.util.logging.Logger;
29
import java.security.PrivilegedAction;
30
31
/**
32
* Parameters that users will not likely need to set
33
* but are useful for debugging
34
*/
35
36
class ServerConfig {
37
38
private static final int DEFAULT_CLOCK_TICK = 10000 ; // 10 sec.
39
40
/* These values must be a reasonable multiple of clockTick */
41
private static final long DEFAULT_IDLE_INTERVAL = 30 ; // 5 min
42
private static final int DEFAULT_MAX_IDLE_CONNECTIONS = 200 ;
43
44
private static final long DEFAULT_MAX_REQ_TIME = -1; // default: forever
45
private static final long DEFAULT_MAX_RSP_TIME = -1; // default: forever
46
private static final long DEFAULT_TIMER_MILLIS = 1000;
47
private static final int DEFAULT_MAX_REQ_HEADERS = 200;
48
private static final long DEFAULT_DRAIN_AMOUNT = 64 * 1024;
49
50
private static int clockTick;
51
private static long idleInterval;
52
// The maximum number of bytes to drain from an inputstream
53
private static long drainAmount;
54
private static int maxIdleConnections;
55
// The maximum number of request headers allowable
56
private static int maxReqHeaders;
57
// max time a request or response is allowed to take
58
private static long maxReqTime;
59
private static long maxRspTime;
60
private static long timerMillis;
61
private static boolean debug;
62
63
// the value of the TCP_NODELAY socket-level option
64
private static boolean noDelay;
65
66
static {
67
java.security.AccessController.doPrivileged(
68
new PrivilegedAction<Void>() {
69
@Override
70
public Void run () {
71
idleInterval = Long.getLong("sun.net.httpserver.idleInterval",
72
DEFAULT_IDLE_INTERVAL) * 1000;
73
74
clockTick = Integer.getInteger("sun.net.httpserver.clockTick",
75
DEFAULT_CLOCK_TICK);
76
77
maxIdleConnections = Integer.getInteger(
78
"sun.net.httpserver.maxIdleConnections",
79
DEFAULT_MAX_IDLE_CONNECTIONS);
80
81
drainAmount = Long.getLong("sun.net.httpserver.drainAmount",
82
DEFAULT_DRAIN_AMOUNT);
83
84
maxReqHeaders = Integer.getInteger(
85
"sun.net.httpserver.maxReqHeaders",
86
DEFAULT_MAX_REQ_HEADERS);
87
88
maxReqTime = Long.getLong("sun.net.httpserver.maxReqTime",
89
DEFAULT_MAX_REQ_TIME);
90
91
maxRspTime = Long.getLong("sun.net.httpserver.maxRspTime",
92
DEFAULT_MAX_RSP_TIME);
93
94
timerMillis = Long.getLong("sun.net.httpserver.timerMillis",
95
DEFAULT_TIMER_MILLIS);
96
97
debug = Boolean.getBoolean("sun.net.httpserver.debug");
98
99
noDelay = Boolean.getBoolean("sun.net.httpserver.nodelay");
100
101
return null;
102
}
103
});
104
105
}
106
107
static void checkLegacyProperties(final Logger logger) {
108
109
// legacy properties that are no longer used
110
// print a warning to logger if they are set.
111
112
java.security.AccessController.doPrivileged(
113
new PrivilegedAction<Void>() {
114
public Void run () {
115
if (System.getProperty("sun.net.httpserver.readTimeout")
116
!=null)
117
{
118
logger.warning ("sun.net.httpserver.readTimeout "+
119
"property is no longer used. "+
120
"Use sun.net.httpserver.maxReqTime instead."
121
);
122
}
123
if (System.getProperty("sun.net.httpserver.writeTimeout")
124
!=null)
125
{
126
logger.warning ("sun.net.httpserver.writeTimeout "+
127
"property is no longer used. Use "+
128
"sun.net.httpserver.maxRspTime instead."
129
);
130
}
131
if (System.getProperty("sun.net.httpserver.selCacheTimeout")
132
!=null)
133
{
134
logger.warning ("sun.net.httpserver.selCacheTimeout "+
135
"property is no longer used."
136
);
137
}
138
return null;
139
}
140
}
141
);
142
}
143
144
static boolean debugEnabled() {
145
return debug;
146
}
147
148
static long getIdleInterval() {
149
return idleInterval;
150
}
151
152
static int getClockTick() {
153
return clockTick;
154
}
155
156
static int getMaxIdleConnections() {
157
return maxIdleConnections;
158
}
159
160
static long getDrainAmount() {
161
return drainAmount;
162
}
163
164
static int getMaxReqHeaders() {
165
return maxReqHeaders;
166
}
167
168
static long getMaxReqTime() {
169
return maxReqTime;
170
}
171
172
static long getMaxRspTime() {
173
return maxRspTime;
174
}
175
176
static long getTimerMillis() {
177
return timerMillis;
178
}
179
180
static boolean noDelay() {
181
return noDelay;
182
}
183
}
184
185