/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
*/ package org.apache.coyote.http2;
privatestaticfinal Log log = LogFactory.getLog(Http2Protocol.class); privatestaticfinal StringManager sm = StringManager.getManager(Http2Protocol.class);
staticfinallong DEFAULT_READ_TIMEOUT = 5000; staticfinallong DEFAULT_WRITE_TIMEOUT = 5000; staticfinallong DEFAULT_KEEP_ALIVE_TIMEOUT = 20000; staticfinallong DEFAULT_STREAM_READ_TIMEOUT = 20000; staticfinallong DEFAULT_STREAM_WRITE_TIMEOUT = 20000; // The HTTP/2 specification recommends a minimum default of 100 staticfinallong DEFAULT_MAX_CONCURRENT_STREAMS = 100; // Maximum amount of streams which can be concurrently executed over // a single connection staticfinalint DEFAULT_MAX_CONCURRENT_STREAM_EXECUTION = 20; // Default factor used when adjusting overhead count for overhead frames staticfinalint DEFAULT_OVERHEAD_COUNT_FACTOR = 10; // Default factor used when adjusting overhead count for reset frames staticfinalint DEFAULT_OVERHEAD_RESET_FACTOR = 50; // Not currently configurable. This makes the practical limit for // overheadCountFactor to be ~20. The exact limit will vary with traffic // patterns. staticfinalint DEFAULT_OVERHEAD_REDUCTION_FACTOR = -20; staticfinalint DEFAULT_OVERHEAD_CONTINUATION_THRESHOLD = 1024; staticfinalint DEFAULT_OVERHEAD_DATA_THRESHOLD = 1024; staticfinalint DEFAULT_OVERHEAD_WINDOW_UPDATE_THRESHOLD = 1024;
// All timeouts in milliseconds // These are the socket level timeouts privatelong readTimeout = DEFAULT_READ_TIMEOUT; privatelong writeTimeout = DEFAULT_WRITE_TIMEOUT; privatelong keepAliveTimeout = DEFAULT_KEEP_ALIVE_TIMEOUT; // These are the stream level timeouts privatelong streamReadTimeout = DEFAULT_STREAM_READ_TIMEOUT; privatelong streamWriteTimeout = DEFAULT_STREAM_WRITE_TIMEOUT;
privatelong maxConcurrentStreams = DEFAULT_MAX_CONCURRENT_STREAMS; privateint maxConcurrentStreamExecution = DEFAULT_MAX_CONCURRENT_STREAM_EXECUTION; // To advertise a different default to the client specify it here but DO NOT // change the default defined in ConnectionSettingsBase. privateint initialWindowSize = ConnectionSettingsBase.DEFAULT_INITIAL_WINDOW_SIZE; // Limits privateint maxHeaderCount = Constants.DEFAULT_MAX_HEADER_COUNT; privateint maxTrailerCount = Constants.DEFAULT_MAX_TRAILER_COUNT; privateint overheadCountFactor = DEFAULT_OVERHEAD_COUNT_FACTOR; privateint overheadResetFactor = DEFAULT_OVERHEAD_RESET_FACTOR; privateint overheadContinuationThreshold = DEFAULT_OVERHEAD_CONTINUATION_THRESHOLD; privateint overheadDataThreshold = DEFAULT_OVERHEAD_DATA_THRESHOLD; privateint overheadWindowUpdateThreshold = DEFAULT_OVERHEAD_WINDOW_UPDATE_THRESHOLD;
privateboolean initiatePingDisabled = false; privateboolean useSendfile = true; // Reference to HTTP/1.1 protocol that this instance is configured under private AbstractHttp11Protocol<?> http11Protocol = null;
private RequestGroupInfo global = new RequestGroupInfo();
@Override public String getHttpUpgradeName(boolean isSSLEnabled) { if (isSSLEnabled) { returnnull;
} else { return HTTP_UPGRADE_NAME;
}
}
@Override public String getAlpnName() { return ALPN_NAME;
}
@Override public Processor getProcessor(SocketWrapperBase<?> socketWrapper, Adapter adapter) {
String upgradeProtocol = getUpgradeProtocolName();
UpgradeProcessorInternal processor = new UpgradeProcessorInternal(socketWrapper, new UpgradeToken(getInternalUpgradeHandler(socketWrapper, adapter, null), null, null, upgradeProtocol), null); return processor;
}
@Override public InternalHttpUpgradeHandler getInternalUpgradeHandler(SocketWrapperBase<?> socketWrapper, Adapter adapter,
Request coyoteRequest) { return socketWrapper.hasAsyncIO() ? new Http2AsyncUpgradeHandler(this, adapter, coyoteRequest, socketWrapper) : new Http2UpgradeHandler(this, adapter, coyoteRequest, socketWrapper);
}
@Override publicboolean accept(Request request) { // Should only be one HTTP2-Settings header
Enumeration<String> settings = request.getMimeHeaders().values("HTTP2-Settings"); int count = 0; while (settings.hasMoreElements()) {
count++;
settings.nextElement();
} if (count != 1) { returnfalse;
}
Enumeration<String> connection = request.getMimeHeaders().values("Connection"); boolean found = false; while (connection.hasMoreElements() && !found) {
found = connection.nextElement().contains("HTTP2-Settings");
} return found;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.