Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/net/httpserver/ServerConfig.java
38918 views
/*1* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.net.httpserver;2627import java.util.logging.Logger;28import java.security.PrivilegedAction;2930/**31* Parameters that users will not likely need to set32* but are useful for debugging33*/3435class ServerConfig {3637private static final int DEFAULT_CLOCK_TICK = 10000 ; // 10 sec.3839/* These values must be a reasonable multiple of clockTick */40private static final long DEFAULT_IDLE_INTERVAL = 30 ; // 5 min41private static final int DEFAULT_MAX_IDLE_CONNECTIONS = 200 ;4243private static final long DEFAULT_MAX_REQ_TIME = -1; // default: forever44private static final long DEFAULT_MAX_RSP_TIME = -1; // default: forever45private static final long DEFAULT_TIMER_MILLIS = 1000;46private static final int DEFAULT_MAX_REQ_HEADERS = 200;47private static final long DEFAULT_DRAIN_AMOUNT = 64 * 1024;4849private static int clockTick;50private static long idleInterval;51// The maximum number of bytes to drain from an inputstream52private static long drainAmount;53private static int maxIdleConnections;54// The maximum number of request headers allowable55private static int maxReqHeaders;56// max time a request or response is allowed to take57private static long maxReqTime;58private static long maxRspTime;59private static long timerMillis;60private static boolean debug;6162// the value of the TCP_NODELAY socket-level option63private static boolean noDelay;6465static {66java.security.AccessController.doPrivileged(67new PrivilegedAction<Void>() {68@Override69public Void run () {70idleInterval = Long.getLong("sun.net.httpserver.idleInterval",71DEFAULT_IDLE_INTERVAL) * 1000;7273clockTick = Integer.getInteger("sun.net.httpserver.clockTick",74DEFAULT_CLOCK_TICK);7576maxIdleConnections = Integer.getInteger(77"sun.net.httpserver.maxIdleConnections",78DEFAULT_MAX_IDLE_CONNECTIONS);7980drainAmount = Long.getLong("sun.net.httpserver.drainAmount",81DEFAULT_DRAIN_AMOUNT);8283maxReqHeaders = Integer.getInteger(84"sun.net.httpserver.maxReqHeaders",85DEFAULT_MAX_REQ_HEADERS);8687maxReqTime = Long.getLong("sun.net.httpserver.maxReqTime",88DEFAULT_MAX_REQ_TIME);8990maxRspTime = Long.getLong("sun.net.httpserver.maxRspTime",91DEFAULT_MAX_RSP_TIME);9293timerMillis = Long.getLong("sun.net.httpserver.timerMillis",94DEFAULT_TIMER_MILLIS);9596debug = Boolean.getBoolean("sun.net.httpserver.debug");9798noDelay = Boolean.getBoolean("sun.net.httpserver.nodelay");99100return null;101}102});103104}105106static void checkLegacyProperties(final Logger logger) {107108// legacy properties that are no longer used109// print a warning to logger if they are set.110111java.security.AccessController.doPrivileged(112new PrivilegedAction<Void>() {113public Void run () {114if (System.getProperty("sun.net.httpserver.readTimeout")115!=null)116{117logger.warning ("sun.net.httpserver.readTimeout "+118"property is no longer used. "+119"Use sun.net.httpserver.maxReqTime instead."120);121}122if (System.getProperty("sun.net.httpserver.writeTimeout")123!=null)124{125logger.warning ("sun.net.httpserver.writeTimeout "+126"property is no longer used. Use "+127"sun.net.httpserver.maxRspTime instead."128);129}130if (System.getProperty("sun.net.httpserver.selCacheTimeout")131!=null)132{133logger.warning ("sun.net.httpserver.selCacheTimeout "+134"property is no longer used."135);136}137return null;138}139}140);141}142143static boolean debugEnabled() {144return debug;145}146147static long getIdleInterval() {148return idleInterval;149}150151static int getClockTick() {152return clockTick;153}154155static int getMaxIdleConnections() {156return maxIdleConnections;157}158159static long getDrainAmount() {160return drainAmount;161}162163static int getMaxReqHeaders() {164return maxReqHeaders;165}166167static long getMaxReqTime() {168return maxReqTime;169}170171static long getMaxRspTime() {172return maxRspTime;173}174175static long getTimerMillis() {176return timerMillis;177}178179static boolean noDelay() {180return noDelay;181}182}183184185