SPDY: remove SPDY/3 support
This commit is contained in:
parent
527347094a
commit
a3bff7b89e
@ -38,7 +38,6 @@ public abstract class SpdyOrHttpChooser implements ChannelUpstreamHandler {
|
|||||||
|
|
||||||
public enum SelectedProtocol {
|
public enum SelectedProtocol {
|
||||||
SpdyVersion3_1,
|
SpdyVersion3_1,
|
||||||
SpdyVersion3,
|
|
||||||
HttpVersion1_1,
|
HttpVersion1_1,
|
||||||
HttpVersion1_0,
|
HttpVersion1_0,
|
||||||
None
|
None
|
||||||
@ -73,9 +72,6 @@ public abstract class SpdyOrHttpChooser implements ChannelUpstreamHandler {
|
|||||||
case None:
|
case None:
|
||||||
// Not done with choosing the protocol, so just return here for now,
|
// Not done with choosing the protocol, so just return here for now,
|
||||||
return;
|
return;
|
||||||
case SpdyVersion3:
|
|
||||||
addSpdyHandlers(ctx, SpdyVersion.SPDY_3);
|
|
||||||
break;
|
|
||||||
case SpdyVersion3_1:
|
case SpdyVersion3_1:
|
||||||
addSpdyHandlers(ctx, SpdyVersion.SPDY_3_1);
|
addSpdyHandlers(ctx, SpdyVersion.SPDY_3_1);
|
||||||
break;
|
break;
|
||||||
@ -126,10 +122,9 @@ public abstract class SpdyOrHttpChooser implements ChannelUpstreamHandler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the {@link ChannelUpstreamHandler} that is responsible for handling the {@link HttpRequest}'s
|
* Create the {@link ChannelUpstreamHandler} that is responsible for handling the {@link HttpRequest}'s
|
||||||
* when the {@link SelectedProtocol} was {@link SelectedProtocol#SpdyVersion3} or
|
* when the {@link SelectedProtocol} was {@link SelectedProtocol#SpdyVersion3_1}.
|
||||||
* {@link SelectedProtocol#SpdyVersion3_1}.
|
|
||||||
*
|
*
|
||||||
* Bye default this method will just delecate to {@link #createHttpRequestHandlerForHttp()}, but
|
* By default this method will just delecate to {@link #createHttpRequestHandlerForHttp()}, but
|
||||||
* sub-classes may override this to change the behaviour.
|
* sub-classes may override this to change the behaviour.
|
||||||
*/
|
*/
|
||||||
protected ChannelUpstreamHandler createHttpRequestHandlerForSpdy() {
|
protected ChannelUpstreamHandler createHttpRequestHandlerForSpdy() {
|
||||||
|
@ -63,7 +63,6 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
|
|
||||||
private final boolean server;
|
private final boolean server;
|
||||||
private final int minorVersion;
|
private final int minorVersion;
|
||||||
private final boolean sessionFlowControl;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new session handler.
|
* Creates a new session handler.
|
||||||
@ -80,7 +79,6 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
}
|
}
|
||||||
this.server = server;
|
this.server = server;
|
||||||
minorVersion = spdyVersion.getMinorVersion();
|
minorVersion = spdyVersion.getMinorVersion();
|
||||||
sessionFlowControl = spdyVersion.useSessionFlowControl();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -116,26 +114,24 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
|
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
|
||||||
int streamId = spdyDataFrame.getStreamId();
|
int streamId = spdyDataFrame.getStreamId();
|
||||||
|
|
||||||
if (sessionFlowControl) {
|
int deltaWindowSize = -1 * spdyDataFrame.getData().readableBytes();
|
||||||
int deltaWindowSize = -1 * spdyDataFrame.getData().readableBytes();
|
int newSessionWindowSize =
|
||||||
int newSessionWindowSize =
|
spdySession.updateReceiveWindowSize(SPDY_SESSION_STREAM_ID, deltaWindowSize);
|
||||||
spdySession.updateReceiveWindowSize(SPDY_SESSION_STREAM_ID, deltaWindowSize);
|
|
||||||
|
|
||||||
// Check if session window size is reduced beyond allowable lower bound
|
// Check if session window size is reduced beyond allowable lower bound
|
||||||
if (newSessionWindowSize < 0) {
|
if (newSessionWindowSize < 0) {
|
||||||
issueSessionError(ctx, e.getChannel(), e.getRemoteAddress(), SpdySessionStatus.PROTOCOL_ERROR);
|
issueSessionError(ctx, e.getChannel(), e.getRemoteAddress(), SpdySessionStatus.PROTOCOL_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send a WINDOW_UPDATE frame if less than half the session window size remains
|
// Send a WINDOW_UPDATE frame if less than half the session window size remains
|
||||||
if (newSessionWindowSize <= initialReceiveWindowSize / 2) {
|
if (newSessionWindowSize <= initialReceiveWindowSize / 2) {
|
||||||
deltaWindowSize = initialReceiveWindowSize - newSessionWindowSize;
|
int sessionDeltaWindowSize = initialReceiveWindowSize - newSessionWindowSize;
|
||||||
spdySession.updateReceiveWindowSize(SPDY_SESSION_STREAM_ID, deltaWindowSize);
|
spdySession.updateReceiveWindowSize(SPDY_SESSION_STREAM_ID, sessionDeltaWindowSize);
|
||||||
SpdyWindowUpdateFrame spdyWindowUpdateFrame =
|
SpdyWindowUpdateFrame spdyWindowUpdateFrame =
|
||||||
new DefaultSpdyWindowUpdateFrame(SPDY_SESSION_STREAM_ID, deltaWindowSize);
|
new DefaultSpdyWindowUpdateFrame(SPDY_SESSION_STREAM_ID, sessionDeltaWindowSize);
|
||||||
Channels.write(
|
Channels.write(
|
||||||
ctx, Channels.future(e.getChannel()), spdyWindowUpdateFrame, e.getRemoteAddress());
|
ctx, Channels.future(e.getChannel()), spdyWindowUpdateFrame, e.getRemoteAddress());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we received a data frame for a Stream-ID which is not open
|
// Check if we received a data frame for a Stream-ID which is not open
|
||||||
@ -167,7 +163,6 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Update receive window size
|
// Update receive window size
|
||||||
int deltaWindowSize = -1 * spdyDataFrame.getData().readableBytes();
|
|
||||||
int newWindowSize = spdySession.updateReceiveWindowSize(streamId, deltaWindowSize);
|
int newWindowSize = spdySession.updateReceiveWindowSize(streamId, deltaWindowSize);
|
||||||
|
|
||||||
// Window size can become negative if we sent a SETTINGS frame that reduces the
|
// Window size can become negative if we sent a SETTINGS frame that reduces the
|
||||||
@ -192,10 +187,10 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
|
|
||||||
// Send a WINDOW_UPDATE frame if less than half the stream window size remains
|
// Send a WINDOW_UPDATE frame if less than half the stream window size remains
|
||||||
if (newWindowSize <= initialReceiveWindowSize / 2 && !spdyDataFrame.isLast()) {
|
if (newWindowSize <= initialReceiveWindowSize / 2 && !spdyDataFrame.isLast()) {
|
||||||
deltaWindowSize = initialReceiveWindowSize - newWindowSize;
|
int streamDeltaWindowSize = initialReceiveWindowSize - newWindowSize;
|
||||||
spdySession.updateReceiveWindowSize(streamId, deltaWindowSize);
|
spdySession.updateReceiveWindowSize(streamId, streamDeltaWindowSize);
|
||||||
SpdyWindowUpdateFrame spdyWindowUpdateFrame =
|
SpdyWindowUpdateFrame spdyWindowUpdateFrame =
|
||||||
new DefaultSpdyWindowUpdateFrame(streamId, deltaWindowSize);
|
new DefaultSpdyWindowUpdateFrame(streamId, streamDeltaWindowSize);
|
||||||
Channels.write(
|
Channels.write(
|
||||||
ctx, Channels.future(e.getChannel()), spdyWindowUpdateFrame, e.getRemoteAddress());
|
ctx, Channels.future(e.getChannel()), spdyWindowUpdateFrame, e.getRemoteAddress());
|
||||||
}
|
}
|
||||||
@ -480,11 +475,8 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
synchronized (flowControlLock) {
|
synchronized (flowControlLock) {
|
||||||
int dataLength = spdyDataFrame.getData().readableBytes();
|
int dataLength = spdyDataFrame.getData().readableBytes();
|
||||||
int sendWindowSize = spdySession.getSendWindowSize(streamId);
|
int sendWindowSize = spdySession.getSendWindowSize(streamId);
|
||||||
|
int sessionSendWindowSize = spdySession.getSendWindowSize(SPDY_SESSION_STREAM_ID);
|
||||||
if (sessionFlowControl) {
|
sendWindowSize = Math.min(sendWindowSize, sessionSendWindowSize);
|
||||||
int sessionSendWindowSize = spdySession.getSendWindowSize(SPDY_SESSION_STREAM_ID);
|
|
||||||
sendWindowSize = Math.min(sendWindowSize, sessionSendWindowSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sendWindowSize <= 0) {
|
if (sendWindowSize <= 0) {
|
||||||
// Stream is stalled -- enqueue Data frame and return
|
// Stream is stalled -- enqueue Data frame and return
|
||||||
@ -493,9 +485,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
} else if (sendWindowSize < dataLength) {
|
} else if (sendWindowSize < dataLength) {
|
||||||
// Stream is not stalled but we cannot send the entire frame
|
// Stream is not stalled but we cannot send the entire frame
|
||||||
spdySession.updateSendWindowSize(streamId, -1 * sendWindowSize);
|
spdySession.updateSendWindowSize(streamId, -1 * sendWindowSize);
|
||||||
if (sessionFlowControl) {
|
spdySession.updateSendWindowSize(SPDY_SESSION_STREAM_ID, -1 * sendWindowSize);
|
||||||
spdySession.updateSendWindowSize(SPDY_SESSION_STREAM_ID, -1 * sendWindowSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a partial data frame whose length is the current window size
|
// Create a partial data frame whose length is the current window size
|
||||||
SpdyDataFrame partialDataFrame = new DefaultSpdyDataFrame(streamId);
|
SpdyDataFrame partialDataFrame = new DefaultSpdyDataFrame(streamId);
|
||||||
@ -525,9 +515,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
} else {
|
} else {
|
||||||
// Window size is large enough to send entire data frame
|
// Window size is large enough to send entire data frame
|
||||||
spdySession.updateSendWindowSize(streamId, -1 * dataLength);
|
spdySession.updateSendWindowSize(streamId, -1 * dataLength);
|
||||||
if (sessionFlowControl) {
|
spdySession.updateSendWindowSize(SPDY_SESSION_STREAM_ID, -1 * dataLength);
|
||||||
spdySession.updateSendWindowSize(SPDY_SESSION_STREAM_ID, -1 * dataLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The transfer window size is pre-decremented when sending a data frame downstream.
|
// The transfer window size is pre-decremented when sending a data frame downstream.
|
||||||
// Close the session on write failures that leaves the transfer window in a corrupt state.
|
// Close the session on write failures that leaves the transfer window in a corrupt state.
|
||||||
@ -770,7 +758,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
private void updateSendWindowSize(ChannelHandlerContext ctx, int streamId, int deltaWindowSize) {
|
private void updateSendWindowSize(ChannelHandlerContext ctx, int streamId, int deltaWindowSize) {
|
||||||
synchronized (flowControlLock) {
|
synchronized (flowControlLock) {
|
||||||
int newWindowSize = spdySession.updateSendWindowSize(streamId, deltaWindowSize);
|
int newWindowSize = spdySession.updateSendWindowSize(streamId, deltaWindowSize);
|
||||||
if (sessionFlowControl && streamId != SPDY_SESSION_STREAM_ID) {
|
if (streamId != SPDY_SESSION_STREAM_ID) {
|
||||||
int sessionSendWindowSize = spdySession.getSendWindowSize(SPDY_SESSION_STREAM_ID);
|
int sessionSendWindowSize = spdySession.getSendWindowSize(SPDY_SESSION_STREAM_ID);
|
||||||
newWindowSize = Math.min(newWindowSize, sessionSendWindowSize);
|
newWindowSize = Math.min(newWindowSize, sessionSendWindowSize);
|
||||||
}
|
}
|
||||||
@ -785,7 +773,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) e.getMessage();
|
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) e.getMessage();
|
||||||
int dataFrameSize = spdyDataFrame.getData().readableBytes();
|
int dataFrameSize = spdyDataFrame.getData().readableBytes();
|
||||||
int writeStreamId = spdyDataFrame.getStreamId();
|
int writeStreamId = spdyDataFrame.getStreamId();
|
||||||
if (sessionFlowControl && streamId == SPDY_SESSION_STREAM_ID) {
|
if (streamId == SPDY_SESSION_STREAM_ID) {
|
||||||
newWindowSize = Math.min(newWindowSize, spdySession.getSendWindowSize(writeStreamId));
|
newWindowSize = Math.min(newWindowSize, spdySession.getSendWindowSize(writeStreamId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -793,11 +781,9 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
// Window size is large enough to send entire data frame
|
// Window size is large enough to send entire data frame
|
||||||
spdySession.removePendingWrite(writeStreamId);
|
spdySession.removePendingWrite(writeStreamId);
|
||||||
newWindowSize = spdySession.updateSendWindowSize(writeStreamId, -1 * dataFrameSize);
|
newWindowSize = spdySession.updateSendWindowSize(writeStreamId, -1 * dataFrameSize);
|
||||||
if (sessionFlowControl) {
|
int sessionSendWindowSize =
|
||||||
int sessionSendWindowSize =
|
spdySession.updateSendWindowSize(SPDY_SESSION_STREAM_ID, -1 * dataFrameSize);
|
||||||
spdySession.updateSendWindowSize(SPDY_SESSION_STREAM_ID, -1 * dataFrameSize);
|
newWindowSize = Math.min(newWindowSize, sessionSendWindowSize);
|
||||||
newWindowSize = Math.min(newWindowSize, sessionSendWindowSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The transfer window size is pre-decremented when sending a data frame downstream.
|
// The transfer window size is pre-decremented when sending a data frame downstream.
|
||||||
// Close the session on write failures that leaves the transfer window in a corrupt state.
|
// Close the session on write failures that leaves the transfer window in a corrupt state.
|
||||||
@ -821,9 +807,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
} else {
|
} else {
|
||||||
// We can send a partial frame
|
// We can send a partial frame
|
||||||
spdySession.updateSendWindowSize(writeStreamId, -1 * newWindowSize);
|
spdySession.updateSendWindowSize(writeStreamId, -1 * newWindowSize);
|
||||||
if (sessionFlowControl) {
|
spdySession.updateSendWindowSize(SPDY_SESSION_STREAM_ID, -1 * newWindowSize);
|
||||||
spdySession.updateSendWindowSize(SPDY_SESSION_STREAM_ID, -1 * newWindowSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a partial data frame whose length is the current window size
|
// Create a partial data frame whose length is the current window size
|
||||||
SpdyDataFrame partialDataFrame = new DefaultSpdyDataFrame(writeStreamId);
|
SpdyDataFrame partialDataFrame = new DefaultSpdyDataFrame(writeStreamId);
|
||||||
|
@ -16,17 +16,14 @@
|
|||||||
package org.jboss.netty.handler.codec.spdy;
|
package org.jboss.netty.handler.codec.spdy;
|
||||||
|
|
||||||
public enum SpdyVersion {
|
public enum SpdyVersion {
|
||||||
SPDY_3 (3, 0, false),
|
SPDY_3_1 (3, 1);
|
||||||
SPDY_3_1 (3, 1, true);
|
|
||||||
|
|
||||||
private final int version;
|
private final int version;
|
||||||
private final int minorVerison;
|
private final int minorVerison;
|
||||||
private final boolean sessionFlowControl;
|
|
||||||
|
|
||||||
private SpdyVersion(int version, int minorVersion, boolean sessionFlowControl) {
|
private SpdyVersion(int version, int minorVersion) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.minorVerison = minorVersion;
|
this.minorVerison = minorVersion;
|
||||||
this.sessionFlowControl = sessionFlowControl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int getVersion() {
|
int getVersion() {
|
||||||
@ -36,8 +33,4 @@ public enum SpdyVersion {
|
|||||||
int getMinorVersion() {
|
int getMinorVersion() {
|
||||||
return minorVerison;
|
return minorVerison;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean useSessionFlowControl() {
|
|
||||||
return sessionFlowControl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,6 @@ public abstract class AbstractSocketSpdyEchoTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSpdyEcho() throws Throwable {
|
public void testSpdyEcho() throws Throwable {
|
||||||
testSpdyEcho(SpdyVersion.SPDY_3);
|
|
||||||
testSpdyEcho(SpdyVersion.SPDY_3_1);
|
testSpdyEcho(SpdyVersion.SPDY_3_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,6 @@ public class SpdyFrameDecoderTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTooLargeHeaderNameOnSynStreamRequest() throws Exception {
|
public void testTooLargeHeaderNameOnSynStreamRequest() throws Exception {
|
||||||
testTooLargeHeaderNameOnSynStreamRequest(SpdyVersion.SPDY_3);
|
|
||||||
testTooLargeHeaderNameOnSynStreamRequest(SpdyVersion.SPDY_3_1);
|
testTooLargeHeaderNameOnSynStreamRequest(SpdyVersion.SPDY_3_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +93,6 @@ public class SpdyFrameDecoderTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLargeHeaderNameOnSynStreamRequest() throws Exception {
|
public void testLargeHeaderNameOnSynStreamRequest() throws Exception {
|
||||||
testLargeHeaderNameOnSynStreamRequest(SpdyVersion.SPDY_3);
|
|
||||||
testLargeHeaderNameOnSynStreamRequest(SpdyVersion.SPDY_3_1);
|
testLargeHeaderNameOnSynStreamRequest(SpdyVersion.SPDY_3_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,37 +200,31 @@ public class SpdySessionHandlerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSpdyClientSessionHandler() {
|
public void testSpdyClientSessionHandler() {
|
||||||
testSpdySessionHandler(SpdyVersion.SPDY_3, false);
|
|
||||||
testSpdySessionHandler(SpdyVersion.SPDY_3_1, false);
|
testSpdySessionHandler(SpdyVersion.SPDY_3_1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSpdyClientSessionHandlerPing() {
|
public void testSpdyClientSessionHandlerPing() {
|
||||||
testSpdySessionHandlerPing(SpdyVersion.SPDY_3, false);
|
|
||||||
testSpdySessionHandlerPing(SpdyVersion.SPDY_3_1, false);
|
testSpdySessionHandlerPing(SpdyVersion.SPDY_3_1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSpdyClientSessionHandlerGoAway() {
|
public void testSpdyClientSessionHandlerGoAway() {
|
||||||
testSpdySessionHandlerGoAway(SpdyVersion.SPDY_3, false);
|
|
||||||
testSpdySessionHandlerGoAway(SpdyVersion.SPDY_3_1, false);
|
testSpdySessionHandlerGoAway(SpdyVersion.SPDY_3_1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSpdyServerSessionHandler() {
|
public void testSpdyServerSessionHandler() {
|
||||||
testSpdySessionHandler(SpdyVersion.SPDY_3, true);
|
|
||||||
testSpdySessionHandler(SpdyVersion.SPDY_3_1, true);
|
testSpdySessionHandler(SpdyVersion.SPDY_3_1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSpdyServerSessionHandlerPing() {
|
public void testSpdyServerSessionHandlerPing() {
|
||||||
testSpdySessionHandlerPing(SpdyVersion.SPDY_3, true);
|
|
||||||
testSpdySessionHandlerPing(SpdyVersion.SPDY_3_1, true);
|
testSpdySessionHandlerPing(SpdyVersion.SPDY_3_1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSpdyServerSessionHandlerGoAway() {
|
public void testSpdyServerSessionHandlerGoAway() {
|
||||||
testSpdySessionHandlerGoAway(SpdyVersion.SPDY_3, true);
|
|
||||||
testSpdySessionHandlerGoAway(SpdyVersion.SPDY_3_1, true);
|
testSpdySessionHandlerGoAway(SpdyVersion.SPDY_3_1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user