SPDY: remove SPDY/3 support
This commit is contained in:
parent
738d3f77b9
commit
b02531f0aa
@ -26,9 +26,8 @@ import io.netty.handler.codec.http.HttpRequestDecoder;
|
||||
import io.netty.handler.codec.http.HttpResponseEncoder;
|
||||
import io.netty.handler.ssl.SslHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* {@link ChannelInboundHandler} which is responsible to setup the {@link ChannelPipeline} either for
|
||||
@ -40,7 +39,6 @@ public abstract class SpdyOrHttpChooser extends ByteToMessageDecoder {
|
||||
// TODO: Replace with generic NPN handler
|
||||
|
||||
public enum SelectedProtocol {
|
||||
SPDY_3("spdy/3"),
|
||||
SPDY_3_1("spdy/3.1"),
|
||||
HTTP_1_1("http/1.1"),
|
||||
HTTP_1_0("http/1.0"),
|
||||
@ -113,9 +111,6 @@ public abstract class SpdyOrHttpChooser extends ByteToMessageDecoder {
|
||||
case UNKNOWN:
|
||||
// Not done with choosing the protocol, so just return here for now,
|
||||
return false;
|
||||
case SPDY_3:
|
||||
addSpdyHandlers(ctx, SpdyVersion.SPDY_3);
|
||||
break;
|
||||
case SPDY_3_1:
|
||||
addSpdyHandlers(ctx, SpdyVersion.SPDY_3_1);
|
||||
break;
|
||||
@ -163,8 +158,7 @@ public abstract class SpdyOrHttpChooser extends ByteToMessageDecoder {
|
||||
|
||||
/**
|
||||
* Create the {@link ChannelInboundHandler} that is responsible for handling the http responses
|
||||
* when the {@link SelectedProtocol} was {@link SelectedProtocol#SPDY_3} or
|
||||
* {@link SelectedProtocol#SPDY_3_1}.
|
||||
* when the {@link SelectedProtocol} was {@link SelectedProtocol#SPDY_3_1}.
|
||||
*
|
||||
* By default this getMethod will just delecate to {@link #createHttpRequestHandlerForHttp()}, but sub-classes may
|
||||
* override this to change the behaviour.
|
||||
|
@ -62,7 +62,6 @@ public class SpdySessionHandler
|
||||
|
||||
private final boolean server;
|
||||
private final int minorVersion;
|
||||
private final boolean sessionFlowControl;
|
||||
|
||||
/**
|
||||
* Creates a new session handler.
|
||||
@ -79,7 +78,6 @@ public class SpdySessionHandler
|
||||
}
|
||||
this.server = server;
|
||||
minorVersion = version.getMinorVersion();
|
||||
sessionFlowControl = version.useSessionFlowControl();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -111,7 +109,6 @@ public class SpdySessionHandler
|
||||
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
|
||||
int streamId = spdyDataFrame.getStreamId();
|
||||
|
||||
if (sessionFlowControl) {
|
||||
int deltaWindowSize = -1 * spdyDataFrame.content().readableBytes();
|
||||
int newSessionWindowSize =
|
||||
spdySession.updateReceiveWindowSize(SPDY_SESSION_STREAM_ID, deltaWindowSize);
|
||||
@ -124,13 +121,12 @@ public class SpdySessionHandler
|
||||
|
||||
// Send a WINDOW_UPDATE frame if less than half the session window size remains
|
||||
if (newSessionWindowSize <= initialReceiveWindowSize / 2) {
|
||||
deltaWindowSize = initialReceiveWindowSize - newSessionWindowSize;
|
||||
spdySession.updateReceiveWindowSize(SPDY_SESSION_STREAM_ID, deltaWindowSize);
|
||||
int sessionDeltaWindowSize = initialReceiveWindowSize - newSessionWindowSize;
|
||||
spdySession.updateReceiveWindowSize(SPDY_SESSION_STREAM_ID, sessionDeltaWindowSize);
|
||||
SpdyWindowUpdateFrame spdyWindowUpdateFrame =
|
||||
new DefaultSpdyWindowUpdateFrame(SPDY_SESSION_STREAM_ID, deltaWindowSize);
|
||||
new DefaultSpdyWindowUpdateFrame(SPDY_SESSION_STREAM_ID, sessionDeltaWindowSize);
|
||||
ctx.writeAndFlush(spdyWindowUpdateFrame);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we received a data frame for a Stream-ID which is not open
|
||||
|
||||
@ -166,7 +162,6 @@ public class SpdySessionHandler
|
||||
*/
|
||||
|
||||
// Update receive window size
|
||||
int deltaWindowSize = -1 * spdyDataFrame.content().readableBytes();
|
||||
int newWindowSize = spdySession.updateReceiveWindowSize(streamId, deltaWindowSize);
|
||||
|
||||
// Window size can become negative if we sent a SETTINGS frame that reduces the
|
||||
@ -192,10 +187,10 @@ public class SpdySessionHandler
|
||||
|
||||
// Send a WINDOW_UPDATE frame if less than half the stream window size remains
|
||||
if (newWindowSize <= initialReceiveWindowSize / 2 && !spdyDataFrame.isLast()) {
|
||||
deltaWindowSize = initialReceiveWindowSize - newWindowSize;
|
||||
spdySession.updateReceiveWindowSize(streamId, deltaWindowSize);
|
||||
int streamDeltaWindowSize = initialReceiveWindowSize - newWindowSize;
|
||||
spdySession.updateReceiveWindowSize(streamId, streamDeltaWindowSize);
|
||||
SpdyWindowUpdateFrame spdyWindowUpdateFrame =
|
||||
new DefaultSpdyWindowUpdateFrame(streamId, deltaWindowSize);
|
||||
new DefaultSpdyWindowUpdateFrame(streamId, streamDeltaWindowSize);
|
||||
ctx.writeAndFlush(spdyWindowUpdateFrame);
|
||||
}
|
||||
|
||||
@ -479,11 +474,8 @@ public class SpdySessionHandler
|
||||
synchronized (flowControlLock) {
|
||||
int dataLength = spdyDataFrame.content().readableBytes();
|
||||
int sendWindowSize = spdySession.getSendWindowSize(streamId);
|
||||
|
||||
if (sessionFlowControl) {
|
||||
int sessionSendWindowSize = spdySession.getSendWindowSize(SPDY_SESSION_STREAM_ID);
|
||||
sendWindowSize = Math.min(sendWindowSize, sessionSendWindowSize);
|
||||
}
|
||||
|
||||
if (sendWindowSize <= 0) {
|
||||
// Stream is stalled -- enqueue Data frame and return
|
||||
@ -492,9 +484,7 @@ public class SpdySessionHandler
|
||||
} else if (sendWindowSize < dataLength) {
|
||||
// Stream is not stalled but we cannot send the entire frame
|
||||
spdySession.updateSendWindowSize(streamId, -1 * sendWindowSize);
|
||||
if (sessionFlowControl) {
|
||||
spdySession.updateSendWindowSize(SPDY_SESSION_STREAM_ID, -1 * sendWindowSize);
|
||||
}
|
||||
|
||||
// Create a partial data frame whose length is the current window size
|
||||
SpdyDataFrame partialDataFrame = new DefaultSpdyDataFrame(streamId,
|
||||
@ -518,9 +508,7 @@ public class SpdySessionHandler
|
||||
} else {
|
||||
// Window size is large enough to send entire data frame
|
||||
spdySession.updateSendWindowSize(streamId, -1 * dataLength);
|
||||
if (sessionFlowControl) {
|
||||
spdySession.updateSendWindowSize(SPDY_SESSION_STREAM_ID, -1 * dataLength);
|
||||
}
|
||||
|
||||
// The transfer window size is pre-decremented when sending a data frame downstream.
|
||||
// Close the session on write failures that leave the transfer window in a corrupt state.
|
||||
@ -759,7 +747,7 @@ public class SpdySessionHandler
|
||||
private void updateSendWindowSize(final ChannelHandlerContext ctx, int streamId, int deltaWindowSize) {
|
||||
synchronized (flowControlLock) {
|
||||
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);
|
||||
newWindowSize = Math.min(newWindowSize, sessionSendWindowSize);
|
||||
}
|
||||
@ -774,7 +762,7 @@ public class SpdySessionHandler
|
||||
SpdyDataFrame spdyDataFrame = pendingWrite.spdyDataFrame;
|
||||
int dataFrameSize = spdyDataFrame.content().readableBytes();
|
||||
int writeStreamId = spdyDataFrame.getStreamId();
|
||||
if (sessionFlowControl && streamId == SPDY_SESSION_STREAM_ID) {
|
||||
if (streamId == SPDY_SESSION_STREAM_ID) {
|
||||
newWindowSize = Math.min(newWindowSize, spdySession.getSendWindowSize(writeStreamId));
|
||||
}
|
||||
|
||||
@ -782,11 +770,9 @@ public class SpdySessionHandler
|
||||
// Window size is large enough to send entire data frame
|
||||
spdySession.removePendingWrite(writeStreamId);
|
||||
newWindowSize = spdySession.updateSendWindowSize(writeStreamId, -1 * dataFrameSize);
|
||||
if (sessionFlowControl) {
|
||||
int sessionSendWindowSize =
|
||||
spdySession.updateSendWindowSize(SPDY_SESSION_STREAM_ID, -1 * dataFrameSize);
|
||||
newWindowSize = Math.min(newWindowSize, sessionSendWindowSize);
|
||||
}
|
||||
|
||||
// Close the local side of the stream if this is the last frame
|
||||
if (spdyDataFrame.isLast()) {
|
||||
@ -806,9 +792,7 @@ public class SpdySessionHandler
|
||||
} else {
|
||||
// We can send a partial frame
|
||||
spdySession.updateSendWindowSize(writeStreamId, -1 * newWindowSize);
|
||||
if (sessionFlowControl) {
|
||||
spdySession.updateSendWindowSize(SPDY_SESSION_STREAM_ID, -1 * newWindowSize);
|
||||
}
|
||||
|
||||
// Create a partial data frame whose length is the current window size
|
||||
SpdyDataFrame partialDataFrame = new DefaultSpdyDataFrame(writeStreamId,
|
||||
|
@ -16,17 +16,14 @@
|
||||
package io.netty.handler.codec.spdy;
|
||||
|
||||
public enum SpdyVersion {
|
||||
SPDY_3 (3, 0, false),
|
||||
SPDY_3_1 (3, 1, true);
|
||||
SPDY_3_1 (3, 1);
|
||||
|
||||
private final int version;
|
||||
private final int minorVersion;
|
||||
private final boolean sessionFlowControl;
|
||||
|
||||
private SpdyVersion(int version, int minorVersion, boolean sessionFlowControl) {
|
||||
private SpdyVersion(int version, int minorVersion) {
|
||||
this.version = version;
|
||||
this.minorVersion = minorVersion;
|
||||
this.sessionFlowControl = sessionFlowControl;
|
||||
}
|
||||
|
||||
int getVersion() {
|
||||
@ -36,8 +33,4 @@ public enum SpdyVersion {
|
||||
int getMinorVersion() {
|
||||
return minorVersion;
|
||||
}
|
||||
|
||||
boolean useSessionFlowControl() {
|
||||
return sessionFlowControl;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,6 @@ public class SpdyFrameDecoderTest {
|
||||
|
||||
@Test
|
||||
public void testTooLargeHeaderNameOnSynStreamRequest() throws Exception {
|
||||
testTooLargeHeaderNameOnSynStreamRequest(SpdyVersion.SPDY_3);
|
||||
testTooLargeHeaderNameOnSynStreamRequest(SpdyVersion.SPDY_3_1);
|
||||
}
|
||||
|
||||
@ -108,7 +107,6 @@ public class SpdyFrameDecoderTest {
|
||||
|
||||
@Test
|
||||
public void testLargeHeaderNameOnSynStreamRequest() throws Exception {
|
||||
testLargeHeaderNameOnSynStreamRequest(SpdyVersion.SPDY_3);
|
||||
testLargeHeaderNameOnSynStreamRequest(SpdyVersion.SPDY_3_1);
|
||||
}
|
||||
|
||||
|
@ -282,48 +282,36 @@ public class SpdySessionHandlerTest {
|
||||
|
||||
@Test
|
||||
public void testSpdyClientSessionHandler() {
|
||||
logger.info("Running: testSpdyClientSessionHandler v3");
|
||||
testSpdySessionHandler(SpdyVersion.SPDY_3, false);
|
||||
logger.info("Running: testSpdyClientSessionHandler v3.1");
|
||||
testSpdySessionHandler(SpdyVersion.SPDY_3_1, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpdyClientSessionHandlerPing() {
|
||||
logger.info("Running: testSpdyClientSessionHandlerPing v3");
|
||||
testSpdySessionHandlerPing(SpdyVersion.SPDY_3, false);
|
||||
logger.info("Running: testSpdyClientSessionHandlerPing v3.1");
|
||||
testSpdySessionHandlerPing(SpdyVersion.SPDY_3_1, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpdyClientSessionHandlerGoAway() {
|
||||
logger.info("Running: testSpdyClientSessionHandlerGoAway v3");
|
||||
testSpdySessionHandlerGoAway(SpdyVersion.SPDY_3, false);
|
||||
logger.info("Running: testSpdyClientSessionHandlerGoAway v3.1");
|
||||
testSpdySessionHandlerGoAway(SpdyVersion.SPDY_3_1, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpdyServerSessionHandler() {
|
||||
logger.info("Running: testSpdyServerSessionHandler v3");
|
||||
testSpdySessionHandler(SpdyVersion.SPDY_3, true);
|
||||
logger.info("Running: testSpdyServerSessionHandler v3.1");
|
||||
testSpdySessionHandler(SpdyVersion.SPDY_3_1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpdyServerSessionHandlerPing() {
|
||||
logger.info("Running: testSpdyServerSessionHandlerPing v3");
|
||||
testSpdySessionHandlerPing(SpdyVersion.SPDY_3, true);
|
||||
logger.info("Running: testSpdyServerSessionHandlerPing v3.1");
|
||||
testSpdySessionHandlerPing(SpdyVersion.SPDY_3_1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpdyServerSessionHandlerGoAway() {
|
||||
logger.info("Running: testSpdyServerSessionHandlerGoAway v3");
|
||||
testSpdySessionHandlerGoAway(SpdyVersion.SPDY_3, true);
|
||||
logger.info("Running: testSpdyServerSessionHandlerGoAway v3.1");
|
||||
testSpdySessionHandlerGoAway(SpdyVersion.SPDY_3_1, true);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class SpdyServerProvider implements ServerProvider {
|
||||
|
||||
@Override
|
||||
public List<String> protocols() {
|
||||
return Arrays.asList("spdy/3.1", "spdy/3", "http/1.1");
|
||||
return Arrays.asList("spdy/3.1", "http/1.1");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -149,10 +149,6 @@ public class SocketSpdyEchoTest extends AbstractSocketTest {
|
||||
|
||||
@Test(timeout = 15000)
|
||||
public void testSpdyEcho() throws Throwable {
|
||||
version = SpdyVersion.SPDY_3;
|
||||
logger.info("Testing against SPDY v3");
|
||||
run();
|
||||
|
||||
version = SpdyVersion.SPDY_3_1;
|
||||
logger.info("Testing against SPDY v3.1");
|
||||
run();
|
||||
@ -162,7 +158,6 @@ public class SocketSpdyEchoTest extends AbstractSocketTest {
|
||||
|
||||
ByteBuf frames;
|
||||
switch (version) {
|
||||
case SPDY_3:
|
||||
case SPDY_3_1:
|
||||
frames = createFrames(3);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user