Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerConfig.java
41159 views
1
/*
2
* Copyright (c) 2005, 2021, 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.lang.System.Logger;
29
import java.lang.System.Logger.Level;
30
import java.security.PrivilegedAction;
31
32
/**
33
* Parameters that users will not likely need to set
34
* but are useful for debugging
35
*/
36
37
@SuppressWarnings("removal")
38
class ServerConfig {
39
40
private static final int DEFAULT_CLOCK_TICK = 10000 ; // 10 sec.
41
42
/* These values must be a reasonable multiple of clockTick */
43
private static final long DEFAULT_IDLE_INTERVAL = 30 ; // 5 min
44
private static final int DEFAULT_MAX_IDLE_CONNECTIONS = 200 ;
45
46
private static final long DEFAULT_MAX_REQ_TIME = -1; // default: forever
47
private static final long DEFAULT_MAX_RSP_TIME = -1; // default: forever
48
private static final long DEFAULT_TIMER_MILLIS = 1000;
49
private static final int DEFAULT_MAX_REQ_HEADERS = 200;
50
private static final long DEFAULT_DRAIN_AMOUNT = 64 * 1024;
51
52
private static int clockTick;
53
private static long idleInterval;
54
// The maximum number of bytes to drain from an inputstream
55
private static long drainAmount;
56
private static int maxIdleConnections;
57
// The maximum number of request headers allowable
58
private static int maxReqHeaders;
59
// max time a request or response is allowed to take
60
private static long maxReqTime;
61
private static long maxRspTime;
62
private static long timerMillis;
63
private static boolean debug;
64
65
// the value of the TCP_NODELAY socket-level option
66
private static boolean noDelay;
67
68
static {
69
java.security.AccessController.doPrivileged(
70
new PrivilegedAction<Void>() {
71
@Override
72
public Void run () {
73
idleInterval = Long.getLong("sun.net.httpserver.idleInterval",
74
DEFAULT_IDLE_INTERVAL) * 1000;
75
76
clockTick = Integer.getInteger("sun.net.httpserver.clockTick",
77
DEFAULT_CLOCK_TICK);
78
79
maxIdleConnections = Integer.getInteger(
80
"sun.net.httpserver.maxIdleConnections",
81
DEFAULT_MAX_IDLE_CONNECTIONS);
82
83
drainAmount = Long.getLong("sun.net.httpserver.drainAmount",
84
DEFAULT_DRAIN_AMOUNT);
85
86
maxReqHeaders = Integer.getInteger(
87
"sun.net.httpserver.maxReqHeaders",
88
DEFAULT_MAX_REQ_HEADERS);
89
90
maxReqTime = Long.getLong("sun.net.httpserver.maxReqTime",
91
DEFAULT_MAX_REQ_TIME);
92
93
maxRspTime = Long.getLong("sun.net.httpserver.maxRspTime",
94
DEFAULT_MAX_RSP_TIME);
95
96
timerMillis = Long.getLong("sun.net.httpserver.timerMillis",
97
DEFAULT_TIMER_MILLIS);
98
99
debug = Boolean.getBoolean("sun.net.httpserver.debug");
100
101
noDelay = Boolean.getBoolean("sun.net.httpserver.nodelay");
102
103
return null;
104
}
105
});
106
107
}
108
109
static void checkLegacyProperties(final Logger logger) {
110
111
// legacy properties that are no longer used
112
// print a warning to logger if they are set.
113
114
java.security.AccessController.doPrivileged(
115
new PrivilegedAction<Void>() {
116
public Void run () {
117
if (System.getProperty("sun.net.httpserver.readTimeout")
118
!=null)
119
{
120
logger.log (Level.WARNING,
121
"sun.net.httpserver.readTimeout "+
122
"property is no longer used. "+
123
"Use sun.net.httpserver.maxReqTime instead."
124
);
125
}
126
if (System.getProperty("sun.net.httpserver.writeTimeout")
127
!=null)
128
{
129
logger.log (Level.WARNING,
130
"sun.net.httpserver.writeTimeout "+
131
"property is no longer used. Use "+
132
"sun.net.httpserver.maxRspTime instead."
133
);
134
}
135
if (System.getProperty("sun.net.httpserver.selCacheTimeout")
136
!=null)
137
{
138
logger.log (Level.WARNING,
139
"sun.net.httpserver.selCacheTimeout "+
140
"property is no longer used."
141
);
142
}
143
return null;
144
}
145
}
146
);
147
}
148
149
static boolean debugEnabled() {
150
return debug;
151
}
152
153
static long getIdleInterval() {
154
return idleInterval;
155
}
156
157
static int getClockTick() {
158
return clockTick;
159
}
160
161
static int getMaxIdleConnections() {
162
return maxIdleConnections;
163
}
164
165
static long getDrainAmount() {
166
return drainAmount;
167
}
168
169
static int getMaxReqHeaders() {
170
return maxReqHeaders;
171
}
172
173
static long getMaxReqTime() {
174
return maxReqTime;
175
}
176
177
static long getMaxRspTime() {
178
return maxRspTime;
179
}
180
181
static long getTimerMillis() {
182
return timerMillis;
183
}
184
185
static boolean noDelay() {
186
return noDelay;
187
}
188
}
189
190