-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Added test for #10805 Zero Dynamic Table * fixed file header * Added test for #10805 Zero Dynamic Table * Fix for #10805 Zero Dynamic Table Set the correct default size for the table. Always send the max table size on the first encode
- Loading branch information
Showing
2 changed files
with
196 additions
and
2 deletions.
There are no files selected for viewing
190 changes: 190 additions & 0 deletions
190
jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/DynamicTableTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995-2022 Mort Bay Consulting Pty Ltd and others. | ||
// ------------------------------------------------------------------------ | ||
// All rights reserved. This program and the accompanying materials | ||
// are made available under the terms of the Eclipse Public License v1.0 | ||
// and Apache License v2.0 which accompanies this distribution. | ||
// | ||
// The Eclipse Public License is available at | ||
// http://www.eclipse.org/legal/epl-v10.html | ||
// | ||
// The Apache License v2.0 is available at | ||
// http://www.opensource.org/licenses/apache2.0.php | ||
// | ||
// You may elect to redistribute this code under either of these licenses. | ||
// ======================================================================== | ||
// | ||
|
||
package org.eclipse.jetty.http2.client; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import org.eclipse.jetty.http.HttpFields; | ||
import org.eclipse.jetty.http.MetaData; | ||
import org.eclipse.jetty.http2.api.Session; | ||
import org.eclipse.jetty.http2.api.Stream; | ||
import org.eclipse.jetty.http2.frames.HeadersFrame; | ||
import org.eclipse.jetty.http2.frames.SettingsFrame; | ||
import org.eclipse.jetty.http2.server.AbstractHTTP2ServerConnectionFactory; | ||
import org.eclipse.jetty.util.Promise; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.CsvSource; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class DynamicTableTest extends AbstractTest | ||
{ | ||
@ParameterizedTest | ||
@CsvSource({"0,-1", "-1,0", "0,0"}) | ||
public void testMaxEncoderTableCapacityZero(int clientMaxCapacity, int serverMaxCapacity) throws Exception | ||
{ | ||
start(new HttpServlet() | ||
{ | ||
@Override | ||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException | ||
{ | ||
resp.setStatus(200); | ||
resp.getOutputStream().close(); | ||
} | ||
}); | ||
|
||
if (clientMaxCapacity >= 0) | ||
client.setMaxEncoderTableCapacity(clientMaxCapacity); | ||
if (serverMaxCapacity >= 0) | ||
connector.getConnectionFactory(AbstractHTTP2ServerConnectionFactory.class).setMaxEncoderTableCapacity(serverMaxCapacity); | ||
|
||
CountDownLatch serverPreface = new CountDownLatch(1); | ||
Session session = newClient(new Session.Listener.Adapter() | ||
{ | ||
@Override | ||
public void onSettings(Session session, SettingsFrame frame) | ||
{ | ||
serverPreface.countDown(); | ||
} | ||
}); | ||
assertTrue(serverPreface.await(5, TimeUnit.SECONDS)); | ||
|
||
MetaData.Request metaData = newRequest("GET", new HttpFields()); | ||
HeadersFrame frame = new HeadersFrame(metaData, null, true); | ||
CountDownLatch latch = new CountDownLatch(1); | ||
session.newStream(frame, new Promise.Adapter<>(), new Stream.Listener.Adapter() | ||
{ | ||
@Override | ||
public void onHeaders(Stream stream, HeadersFrame frame) | ||
{ | ||
MetaData.Response response = (MetaData.Response)frame.getMetaData(); | ||
assertEquals(200, response.getStatus()); | ||
latch.countDown(); | ||
} | ||
}); | ||
|
||
assertTrue(latch.await(5, TimeUnit.SECONDS)); | ||
} | ||
|
||
@ParameterizedTest | ||
@CsvSource({"0,-1", "-1,0", "0,0"}) | ||
public void testMaxDecoderTableCapacityZero(int clientMaxCapacity, int serverMaxCapacity) throws Exception | ||
{ | ||
start(new HttpServlet() | ||
{ | ||
@Override | ||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException | ||
{ | ||
resp.setStatus(200); | ||
resp.getOutputStream().close(); | ||
} | ||
}); | ||
|
||
if (clientMaxCapacity >= 0) | ||
client.setMaxDecoderTableCapacity(clientMaxCapacity); | ||
if (serverMaxCapacity >= 0) | ||
connector.getConnectionFactory(AbstractHTTP2ServerConnectionFactory.class).setMaxDecoderTableCapacity(serverMaxCapacity); | ||
|
||
CountDownLatch serverPreface = new CountDownLatch(1); | ||
Session session = newClient(new Session.Listener.Adapter() | ||
{ | ||
@Override | ||
public void onSettings(Session session, SettingsFrame frame) | ||
{ | ||
serverPreface.countDown(); | ||
} | ||
}); | ||
assertTrue(serverPreface.await(5, TimeUnit.SECONDS)); | ||
|
||
MetaData.Request metaData = newRequest("GET", new HttpFields()); | ||
HeadersFrame frame = new HeadersFrame(metaData, null, true); | ||
CountDownLatch latch = new CountDownLatch(1); | ||
session.newStream(frame, new Promise.Adapter<>(), new Stream.Listener.Adapter() | ||
{ | ||
@Override | ||
public void onHeaders(Stream stream, HeadersFrame frame) | ||
{ | ||
MetaData.Response response = (MetaData.Response)frame.getMetaData(); | ||
assertEquals(200, response.getStatus()); | ||
latch.countDown(); | ||
} | ||
}); | ||
|
||
assertTrue(latch.await(5, TimeUnit.SECONDS)); | ||
} | ||
|
||
@ParameterizedTest | ||
@CsvSource({"0,-1", "-1,0", "0,0"}) | ||
public void testMaxTableCapacityZero(int clientMaxCapacity, int serverMaxCapacity) throws Exception | ||
{ | ||
start(new HttpServlet() | ||
{ | ||
@Override | ||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException | ||
{ | ||
resp.setStatus(200); | ||
resp.getOutputStream().close(); | ||
} | ||
}); | ||
|
||
if (clientMaxCapacity >= 0) | ||
{ | ||
client.setMaxDecoderTableCapacity(clientMaxCapacity); | ||
client.setMaxEncoderTableCapacity(clientMaxCapacity); | ||
} | ||
if (serverMaxCapacity >= 0) | ||
{ | ||
connector.getConnectionFactory(AbstractHTTP2ServerConnectionFactory.class).setMaxEncoderTableCapacity(serverMaxCapacity); | ||
connector.getConnectionFactory(AbstractHTTP2ServerConnectionFactory.class).setMaxDecoderTableCapacity(serverMaxCapacity); | ||
} | ||
|
||
CountDownLatch serverPreface = new CountDownLatch(1); | ||
Session session = newClient(new Session.Listener.Adapter() | ||
{ | ||
@Override | ||
public void onSettings(Session session, SettingsFrame frame) | ||
{ | ||
serverPreface.countDown(); | ||
} | ||
}); | ||
assertTrue(serverPreface.await(5, TimeUnit.SECONDS)); | ||
|
||
MetaData.Request metaData = newRequest("GET", new HttpFields()); | ||
HeadersFrame frame = new HeadersFrame(metaData, null, true); | ||
CountDownLatch latch = new CountDownLatch(1); | ||
session.newStream(frame, new Promise.Adapter<>(), new Stream.Listener.Adapter() | ||
{ | ||
@Override | ||
public void onHeaders(Stream stream, HeadersFrame frame) | ||
{ | ||
MetaData.Response response = (MetaData.Response)frame.getMetaData(); | ||
assertEquals(200, response.getStatus()); | ||
latch.countDown(); | ||
} | ||
}); | ||
|
||
assertTrue(latch.await(5, TimeUnit.SECONDS)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters