/* * 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;
if (connectionUnlimited) { // Effectively unlimited for this test
sendWindowUpdate(0, blockCount * BLOCK_SIZE * 2);
} if (streamUnlimited) { // Effectively unlimited for this test
sendWindowUpdate(3, blockCount * BLOCK_SIZE * 2);
}
// Headers
parser.readFrame(); // Body
if (!connectionUnlimited || !streamUnlimited) { while (output.getBytesRead() < startingWindowSize) {
parser.readFrame();
}
// Check that the right number of bytes were received Assert.assertEquals(startingWindowSize, output.getBytesRead());
// Increase the Window size (50% of total body) int windowSizeIncrease = blockCount * BLOCK_SIZE / 2; if (expandConnectionFirst) {
sendWindowUpdate(0, windowSizeIncrease);
sendWindowUpdate(3, windowSizeIncrease);
} else {
sendWindowUpdate(3, windowSizeIncrease);
sendWindowUpdate(0, windowSizeIncrease);
}
while (output.getBytesRead() < startingWindowSize + windowSizeIncrease) {
parser.readFrame();
}
// Check that the right number of bytes were received Assert.assertEquals(startingWindowSize + windowSizeIncrease, output.getBytesRead());
/* * Not thread-safe. OK for this test. NOt OK for use in the real world.
*/
@Override protectedvoid doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
final AsyncContext asyncContext = request.startAsync();
final ServletOutputStream output = response.getOutputStream();
output.setWriteListener(new WriteListener() {
// Intermittent CI errors were observed where the response body // was exactly one block too small. Use an AtomicInteger to be // sure blockCount is thread-safe. final AtomicInteger blockCount = new AtomicInteger(0); byte[] bytes = newbyte[BLOCK_SIZE];
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.