Author: markt
Date: Tue Aug 18 17:06:22 2015
New Revision: 1696459
URL: http://svn.apache.org/r1696459
Log:
Switch the Http2UpgradeHandler to using ConnectionSettingsLocal
Fix TODO for sending non-default values in initial settings frame including
updating tests
Added:
tomcat/trunk/java/org/apache/coyote/http2/ConnectionSettingsRemote.java
- copied, changed from r1696447,
tomcat/trunk/java/org/apache/coyote/http2/ConnectionSettings.java
Modified:
tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java
tomcat/trunk/test/org/apache/coyote/http2/Http2TestBase.java
tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
Copied: tomcat/trunk/java/org/apache/coyote/http2/ConnectionSettingsRemote.java
(from r1696447,
tomcat/trunk/java/org/apache/coyote/http2/ConnectionSettings.java)
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/ConnectionSettingsRemote.java?p2=tomcat/trunk/java/org/apache/coyote/http2/ConnectionSettingsRemote.java&p1=tomcat/trunk/java/org/apache/coyote/http2/ConnectionSettings.java&r1=1696447&r2=1696459&rev=1696459&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/ConnectionSettings.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/ConnectionSettingsRemote.java Tue
Aug 18 17:06:22 2015
@@ -20,13 +20,17 @@ import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.res.StringManager;
-public class ConnectionSettings {
+/**
+ * Represents the remote connection settings: i.e. the settings the server must
+ * use when communicating with the client.
+ */
+public class ConnectionSettingsRemote {
- private final Log log = LogFactory.getLog(ConnectionSettings.class);
- private final StringManager sm =
StringManager.getManager(ConnectionSettings.class);
+ private final Log log = LogFactory.getLog(ConnectionSettingsRemote.class);
+ private final StringManager sm =
StringManager.getManager(ConnectionSettingsRemote.class);
- public static final int DEFAULT_WINDOW_SIZE = (1 << 16) - 1;
- private static final long UNLIMITED = ((long)1 << 32); // Use the maximum
possible
+ public static final int DEFAULT_INITIAL_WINDOW_SIZE = (1 << 16) - 1;
+ static final long UNLIMITED = ((long)1 << 32); // Use the maximum possible
private static final int MAX_WINDOW_SIZE = (1 << 31) - 1;
private static final int MIN_MAX_FRAME_SIZE = 1 << 14;
@@ -38,7 +42,7 @@ public class ConnectionSettings {
private volatile boolean enablePush = true;
private volatile long maxConcurrentStreams = UNLIMITED;
- private volatile int initialWindowSize = DEFAULT_WINDOW_SIZE;
+ private volatile int initialWindowSize = DEFAULT_INITIAL_WINDOW_SIZE;
private volatile int maxFrameSize = DEFAULT_MAX_FRAME_SIZE;
private volatile long maxHeaderListSize = UNLIMITED;
Modified: tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java?rev=1696459&r1=1696458&r2=1696459&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java
(original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java Tue Aug
18 17:06:22 2015
@@ -115,7 +115,7 @@ public class Http2UpgradeHandler extends
private volatile long pausedNanoTime = Long.MAX_VALUE;
private final ConnectionSettingsRemote remoteSettings = new
ConnectionSettingsRemote();
- private final ConnectionSettingsRemote localSettings = new
ConnectionSettingsRemote();
+ private final ConnectionSettingsLocal localSettings = new
ConnectionSettingsLocal();
private HpackDecoder hpackDecoder;
private HpackEncoder hpackEncoder;
@@ -205,9 +205,9 @@ public class Http2UpgradeHandler extends
}
// Send the initial settings frame
- // TODO: Need to send non-default settings values
try {
- socketWrapper.write(true, SETTINGS_EMPTY, 0,
SETTINGS_EMPTY.length);
+ byte[] settings = localSettings.getSettingsFrameForPending();
+ socketWrapper.write(true, settings, 0, settings.length);
socketWrapper.flush(true);
} catch (IOException ioe) {
throw new
IllegalStateException(sm.getString("upgradeHandler.sendPrefaceFail"), ioe);
@@ -810,25 +810,13 @@ public class Http2UpgradeHandler extends
}
- /*
- * This only has an effect if called before the connection is established
- */
public void setMaxConcurrentStreams(long maxConcurrentStreams) {
localSettings.setMaxConcurrentStreams(maxConcurrentStreams);
}
- /*
- * This only has an effect if called before the connection is established
- */
public void setInitialWindowSize(int initialWindowSize) {
- try {
- localSettings.setInitialWindowSize(initialWindowSize);
- } catch (ConnectionException e) {
- // Illegal setting. Ignore it but log a warning.
- log.warn(sm.getString("upgradeHandler.initialWindowSize.invalid",
- connectionId, Integer.toString(initialWindowSize)));
- }
+ localSettings.setInitialWindowSize(initialWindowSize);
}
@@ -995,7 +983,7 @@ public class Http2UpgradeHandler extends
@Override
public void settingsEnd(boolean ack) throws IOException {
if (ack) {
- // TODO Process ACK
+ localSettings.ack();
} else {
synchronized (socketWrapper) {
socketWrapper.write(true, SETTINGS_ACK, 0,
SETTINGS_ACK.length);
Modified: tomcat/trunk/test/org/apache/coyote/http2/Http2TestBase.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/Http2TestBase.java?rev=1696459&r1=1696458&r2=1696459&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/Http2TestBase.java (original)
+++ tomcat/trunk/test/org/apache/coyote/http2/Http2TestBase.java Tue Aug 18
17:06:22 2015
@@ -92,9 +92,10 @@ public abstract class Http2TestBase exte
protected void validateHttp2InitialResponse() throws Exception {
// - 101 response acts as acknowledgement of the HTTP2-Settings header
- // Need to read 4 frames
+ // Need to read 5 frames
// - settings (server settings - must be first)
// - settings ack (for the settings frame in the client preface)
+ // - ping
// - headers (for response)
// - data (for response body)
parser.readFrame(true);
@@ -103,7 +104,8 @@ public abstract class Http2TestBase exte
parser.readFrame(true);
parser.readFrame(true);
- Assert.assertEquals("0-Settings-End\n" +
+ Assert.assertEquals("0-Settings-[3]-[200]\n" +
+ "0-Settings-End\n" +
"0-Settings-Ack\n" +
"0-Ping-[0,0,0,0,0,0,0,1]\n" +
getSimpleResponseTrace(1)
@@ -596,9 +598,7 @@ public abstract class Http2TestBase exte
void sendSettings(int streamId, boolean ack, Setting... settings) throws
IOException {
- byte[] settingFrame = new byte[15];
// length
-
int settingsCount;
if (settings == null) {
settingsCount = 0;
@@ -606,6 +606,8 @@ public abstract class Http2TestBase exte
settingsCount = settings.length;
}
+ byte[] settingFrame = new byte[9 + 6 * settingsCount];
+
ByteUtil.setThreeBytes(settingFrame, 0, 6 * settingsCount);
// type
settingFrame[3] = FrameType.SETTINGS.getIdByte();
@@ -732,6 +734,12 @@ public abstract class Http2TestBase exte
trace.append("0-Settings-Ack\n");
} else {
trace.append("0-Settings-End\n");
+ try {
+ sendSettings(0, true);
+ } catch (IOException ioe) {
+ // Convert to uncaught exception
+ throw new IllegalStateException(ioe);
+ }
}
}
Modified: tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_1.java?rev=1696459&r1=1696458&r2=1696459&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
(original)
+++ tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_1.java Tue Aug
18 17:06:22 2015
@@ -199,7 +199,21 @@ public class TestHttp2Section_5_1 extend
openClientConnection();
doHttpUpgrade();
sendClientPreface();
- validateHttp2InitialResponse();
+
+ // validateHttp2InitialResponse() - modified
+ parser.readFrame(true);
+ parser.readFrame(true);
+ parser.readFrame(true);
+ parser.readFrame(true);
+ parser.readFrame(true);
+
+ Assert.assertEquals("0-Settings-[3]-[1]\n" +
+ "0-Settings-End\n" +
+ "0-Settings-Ack\n" +
+ "0-Ping-[0,0,0,0,0,0,0,1]\n" +
+ getSimpleResponseTrace(1)
+ , output.getTrace());
+ output.clearTrace();
sendLargeGetRequest(3);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]