Author: markt
Date: Tue Jun 16 21:54:52 2015
New Revision: 1685915
URL: http://svn.apache.org/r1685915
Log:
Implement an HTTP/2 TODO. Add the last 'processed' stream ID to anyGOAWAY frame
sent. 'processed' means passed the container did some processing.
Modified:
tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java
tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_2.java
tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_3.java
tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
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=1685915&r1=1685914&r2=1685915&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java
(original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java Tue Jun
16 21:54:52 2015
@@ -121,6 +121,7 @@ public class Http2UpgradeHandler extends
private volatile int maxRemoteStreamId = 0;
// Start at -1 so the 'add 2' logic in closeIdleStreams() works
private volatile int maxActiveRemoteStreamId = -1;
+ private volatile int maxProcessedStreamId;
// Tracking for when the connection is blocked (windowSize < 1)
private final Object backLogLock = new Object();
@@ -144,6 +145,7 @@ public class Http2UpgradeHandler extends
maxRemoteStreamId = 1;
maxActiveRemoteStreamId = 1;
activeRemoteStreamCount = 1;
+ maxProcessedStreamId = 1;
}
}
@@ -378,8 +380,7 @@ public class Http2UpgradeHandler extends
private void closeConnection(Http2Exception ce) {
// Write a GOAWAY frame.
byte[] fixedPayload = new byte[8];
- // TODO needs to be correct value
- ByteUtil.set31Bits(fixedPayload, 0, (2 << 31) - 1);
+ ByteUtil.set31Bits(fixedPayload, 0, maxProcessedStreamId);
ByteUtil.setFourBytes(fixedPayload, 4, ce.getError().getCode());
byte[] debugMessage = ce.getMessage().getBytes(StandardCharsets.UTF_8);
byte[] payloadLength = new byte[3];
@@ -859,6 +860,7 @@ public class Http2UpgradeHandler extends
@Override
public void headersEnd(int streamId) throws ConnectionException {
+ setMaxProcessedStream(streamId);
Stream stream = getStream(streamId, true);
// Process this stream on a container thread
StreamProcessor streamProcessor = new StreamProcessor(stream, adapter,
socketWrapper);
@@ -867,6 +869,12 @@ public class Http2UpgradeHandler extends
}
+ private void setMaxProcessedStream(int streamId) {
+ if (maxProcessedStreamId < streamId) {
+ maxProcessedStreamId = streamId;
+ }
+ }
+
@Override
public void reset(int streamId, long errorCode) throws Http2Exception {
Modified: tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_2.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_2.java?rev=1685915&r1=1685914&r2=1685915&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_2.java
(original)
+++ tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_2.java Tue Jun
16 21:54:52 2015
@@ -58,9 +58,8 @@ public class TestHttp2Section_4_2 extend
// Read GOAWAY frame
parser.readFrame(true);
- Assert.assertTrue(output.getTrace(),
- output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
- Http2Error.FRAME_SIZE_ERROR.getCode() + "]-["));
+ Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
+ "0-Goaway-[1]-[" + Http2Error.FRAME_SIZE_ERROR.getCode() +
"]-["));
}
@Test
@@ -85,9 +84,8 @@ public class TestHttp2Section_4_2 extend
// Read GOAWAY frame
parser.readFrame(true);
- Assert.assertTrue(output.getTrace(),
- output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
- Http2Error.FRAME_SIZE_ERROR.getCode() + "]-["));
+ Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
+ "0-Goaway-[1]-[" + Http2Error.FRAME_SIZE_ERROR.getCode() +
"]-["));
}
@@ -112,9 +110,8 @@ public class TestHttp2Section_4_2 extend
// Read GOAWAY frame
parser.readFrame(true);
- Assert.assertTrue(output.getTrace(),
- output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
- Http2Error.FRAME_SIZE_ERROR.getCode() + "]-["));
+ Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
+ "0-Goaway-[1]-[" + Http2Error.FRAME_SIZE_ERROR.getCode() +
"]-["));
}
Modified: tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_3.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_3.java?rev=1685915&r1=1685914&r2=1685915&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_3.java
(original)
+++ tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_3.java Tue Jun
16 21:54:52 2015
@@ -49,9 +49,8 @@ public class TestHttp2Section_4_3 extend
// Read GOAWAY frame
parser.readFrame(true);
- Assert.assertTrue(output.getTrace(),
- output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
- Http2Error.COMPRESSION_ERROR.getCode() + "]-["));
+ Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
+ "0-Goaway-[1]-[" + Http2Error.COMPRESSION_ERROR.getCode() +
"]-["));
}
@@ -95,8 +94,7 @@ public class TestHttp2Section_4_3 extend
// Read GOAWAY frame
parser.readFrame(true);
- Assert.assertTrue(output.getTrace(),
- output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
- Http2Error.COMPRESSION_ERROR.getCode() + "]-["));
+ Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
+ "0-Goaway-[1]-[" + Http2Error.COMPRESSION_ERROR.getCode() +
"]-["));
}
}
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=1685915&r1=1685914&r2=1685915&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 Jun
16 21:54:52 2015
@@ -38,9 +38,8 @@ public class TestHttp2Section_5_1 extend
parser.readFrame(true);
- Assert.assertTrue(output.getTrace(),
- output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
- Http2Error.PROTOCOL_ERROR.getCode() + "]-["));
+ Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
+ "0-Goaway-[1]-[" + Http2Error.PROTOCOL_ERROR.getCode() +
"]-["));
}
@@ -52,9 +51,8 @@ public class TestHttp2Section_5_1 extend
parser.readFrame(true);
- Assert.assertTrue(output.getTrace(),
- output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
- Http2Error.PROTOCOL_ERROR.getCode() + "]-["));
+ Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
+ "0-Goaway-[1]-[" + Http2Error.PROTOCOL_ERROR.getCode() +
"]-["));
}
@@ -76,9 +74,8 @@ public class TestHttp2Section_5_1 extend
sendData(3, new byte[] {});
parser.readFrame(true);
- Assert.assertTrue(output.getTrace(),
- output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
- Http2Error.STREAM_CLOSED.getCode() + "]-["));
+ Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
+ "0-Goaway-[3]-[" + Http2Error.STREAM_CLOSED.getCode() +
"]-["));
}
@@ -118,9 +115,8 @@ public class TestHttp2Section_5_1 extend
sendData(1, new byte[] {});
parser.readFrame(true);
- Assert.assertTrue(output.getTrace(),
- output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
- Http2Error.STREAM_CLOSED.getCode() + "]-["));
+ Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
+ "0-Goaway-[1]-[" + Http2Error.STREAM_CLOSED.getCode() +
"]-["));
}
@@ -142,9 +138,8 @@ public class TestHttp2Section_5_1 extend
// headers
parser.readFrame(true);
- Assert.assertTrue(output.getTrace(),
- output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
- Http2Error.PROTOCOL_ERROR.getCode() + "]-["));
+ Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
+ "0-Goaway-[1]-[" + Http2Error.PROTOCOL_ERROR.getCode() +
"]-["));
}
@@ -168,9 +163,8 @@ public class TestHttp2Section_5_1 extend
// headers
parser.readFrame(true);
- Assert.assertTrue(output.getTrace(),
- output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
- Http2Error.PROTOCOL_ERROR.getCode() + "]-["));
+ Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
+ "0-Goaway-[5]-[" + Http2Error.PROTOCOL_ERROR.getCode() +
"]-["));
}
@@ -192,9 +186,8 @@ public class TestHttp2Section_5_1 extend
parser.readFrame(true);
- Assert.assertTrue(output.getTrace(),
- output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
- Http2Error.PROTOCOL_ERROR.getCode() + "]-["));
+ Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
+ "0-Goaway-[5]-[" + Http2Error.PROTOCOL_ERROR.getCode() +
"]-["));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]