Merge pull request #2064 from jpinner/spdy_minor_version
SPDY: add SETTINGS_MINOR_VERSION
This commit is contained in:
commit
f41e2f830d
@ -57,7 +57,7 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SpdySettingsFrame setValue(int id, int value, boolean persistValue, boolean persisted) {
|
public SpdySettingsFrame setValue(int id, int value, boolean persistValue, boolean persisted) {
|
||||||
if (id <= 0 || id > SpdyCodecUtil.SPDY_SETTINGS_MAX_ID) {
|
if (id < 0 || id > SpdyCodecUtil.SPDY_SETTINGS_MAX_ID) {
|
||||||
throw new IllegalArgumentException("Setting ID is not valid: " + id);
|
throw new IllegalArgumentException("Setting ID is not valid: " + id);
|
||||||
}
|
}
|
||||||
Integer key = Integer.valueOf(id);
|
Integer key = Integer.valueOf(id);
|
||||||
|
@ -191,14 +191,6 @@ public class SpdyFrameDecoder extends ByteToMessageDecoder {
|
|||||||
int value = getSignedInt(buffer, buffer.readerIndex() + 4);
|
int value = getSignedInt(buffer, buffer.readerIndex() + 4);
|
||||||
buffer.skipBytes(8);
|
buffer.skipBytes(8);
|
||||||
|
|
||||||
// Check for invalid ID -- avoid IllegalArgumentException in setValue
|
|
||||||
if (ID == 0) {
|
|
||||||
state = State.FRAME_ERROR;
|
|
||||||
spdySettingsFrame = null;
|
|
||||||
fireInvalidFrameException(ctx);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!spdySettingsFrame.isSet(ID)) {
|
if (!spdySettingsFrame.isSet(ID)) {
|
||||||
boolean persistVal = (ID_flags & SPDY_SETTINGS_PERSIST_VALUE) != 0;
|
boolean persistVal = (ID_flags & SPDY_SETTINGS_PERSIST_VALUE) != 0;
|
||||||
boolean persisted = (ID_flags & SPDY_SETTINGS_PERSISTED) != 0;
|
boolean persisted = (ID_flags & SPDY_SETTINGS_PERSISTED) != 0;
|
||||||
|
@ -60,6 +60,7 @@ public class SpdySessionHandler extends ChannelHandlerAdapter {
|
|||||||
private ChannelFutureListener closeSessionFutureListener;
|
private ChannelFutureListener closeSessionFutureListener;
|
||||||
|
|
||||||
private final boolean server;
|
private final boolean server;
|
||||||
|
private final int minorVersion;
|
||||||
private final boolean sessionFlowControl;
|
private final boolean sessionFlowControl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,6 +77,7 @@ public class SpdySessionHandler extends ChannelHandlerAdapter {
|
|||||||
throw new NullPointerException("version");
|
throw new NullPointerException("version");
|
||||||
}
|
}
|
||||||
this.server = server;
|
this.server = server;
|
||||||
|
minorVersion = version.getMinorVersion();
|
||||||
sessionFlowControl = version.useSessionFlowControl();
|
sessionFlowControl = version.useSessionFlowControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,6 +296,13 @@ public class SpdySessionHandler extends ChannelHandlerAdapter {
|
|||||||
|
|
||||||
SpdySettingsFrame spdySettingsFrame = (SpdySettingsFrame) msg;
|
SpdySettingsFrame spdySettingsFrame = (SpdySettingsFrame) msg;
|
||||||
|
|
||||||
|
int settingsMinorVersion = spdySettingsFrame.getValue(SpdySettingsFrame.SETTINGS_MINOR_VERSION);
|
||||||
|
if (settingsMinorVersion >= 0 && settingsMinorVersion != minorVersion) {
|
||||||
|
// Settings frame had the wrong minor version
|
||||||
|
issueSessionError(ctx, SpdySessionStatus.PROTOCOL_ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int newConcurrentStreams =
|
int newConcurrentStreams =
|
||||||
spdySettingsFrame.getValue(SpdySettingsFrame.SETTINGS_MAX_CONCURRENT_STREAMS);
|
spdySettingsFrame.getValue(SpdySettingsFrame.SETTINGS_MAX_CONCURRENT_STREAMS);
|
||||||
if (newConcurrentStreams >= 0) {
|
if (newConcurrentStreams >= 0) {
|
||||||
@ -574,6 +583,13 @@ public class SpdySessionHandler extends ChannelHandlerAdapter {
|
|||||||
|
|
||||||
SpdySettingsFrame spdySettingsFrame = (SpdySettingsFrame) msg;
|
SpdySettingsFrame spdySettingsFrame = (SpdySettingsFrame) msg;
|
||||||
|
|
||||||
|
int settingsMinorVersion = spdySettingsFrame.getValue(SpdySettingsFrame.SETTINGS_MINOR_VERSION);
|
||||||
|
if (settingsMinorVersion >= 0 && settingsMinorVersion != minorVersion) {
|
||||||
|
// Settings frame had the wrong minor version
|
||||||
|
promise.setFailure(PROTOCOL_EXCEPTION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int newConcurrentStreams =
|
int newConcurrentStreams =
|
||||||
spdySettingsFrame.getValue(SpdySettingsFrame.SETTINGS_MAX_CONCURRENT_STREAMS);
|
spdySettingsFrame.getValue(SpdySettingsFrame.SETTINGS_MAX_CONCURRENT_STREAMS);
|
||||||
if (newConcurrentStreams >= 0) {
|
if (newConcurrentStreams >= 0) {
|
||||||
|
@ -22,6 +22,7 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
public interface SpdySettingsFrame extends SpdyFrame {
|
public interface SpdySettingsFrame extends SpdyFrame {
|
||||||
|
|
||||||
|
int SETTINGS_MINOR_VERSION = 0;
|
||||||
int SETTINGS_UPLOAD_BANDWIDTH = 1;
|
int SETTINGS_UPLOAD_BANDWIDTH = 1;
|
||||||
int SETTINGS_DOWNLOAD_BANDWIDTH = 2;
|
int SETTINGS_DOWNLOAD_BANDWIDTH = 2;
|
||||||
int SETTINGS_ROUND_TRIP_TIME = 3;
|
int SETTINGS_ROUND_TRIP_TIME = 3;
|
||||||
@ -50,7 +51,7 @@ public interface SpdySettingsFrame extends SpdyFrame {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value of the setting ID.
|
* Sets the value of the setting ID.
|
||||||
* The ID must be positive and cannot exceed 16777215.
|
* The ID cannot be negative and cannot exceed 16777215.
|
||||||
*/
|
*/
|
||||||
SpdySettingsFrame setValue(int id, int value);
|
SpdySettingsFrame setValue(int id, int value);
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ public interface SpdySettingsFrame extends SpdyFrame {
|
|||||||
* Sets the value of the setting ID.
|
* Sets the value of the setting ID.
|
||||||
* Sets if the setting should be persisted (should only be set by the server).
|
* Sets if the setting should be persisted (should only be set by the server).
|
||||||
* Sets if the setting is persisted (should only be set by the client).
|
* Sets if the setting is persisted (should only be set by the client).
|
||||||
* The ID must be positive and cannot exceed 16777215.
|
* The ID cannot be negative and cannot exceed 16777215.
|
||||||
*/
|
*/
|
||||||
SpdySettingsFrame setValue(int id, int value, boolean persistVal, boolean persisted);
|
SpdySettingsFrame setValue(int id, int value, boolean persistVal, boolean persisted);
|
||||||
|
|
||||||
|
@ -16,14 +16,16 @@
|
|||||||
package io.netty.handler.codec.spdy;
|
package io.netty.handler.codec.spdy;
|
||||||
|
|
||||||
public enum SpdyVersion {
|
public enum SpdyVersion {
|
||||||
SPDY_3 (3, false),
|
SPDY_3 (3, 0, false),
|
||||||
SPDY_3_1 (3, true);
|
SPDY_3_1 (3, 1, true);
|
||||||
|
|
||||||
private final int version;
|
private final int version;
|
||||||
|
private final int minorVersion;
|
||||||
private final boolean sessionFlowControl;
|
private final boolean sessionFlowControl;
|
||||||
|
|
||||||
private SpdyVersion(int version, boolean sessionFlowControl) {
|
private SpdyVersion(int version, int minorVersion, boolean sessionFlowControl) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
this.minorVersion = minorVersion;
|
||||||
this.sessionFlowControl = sessionFlowControl;
|
this.sessionFlowControl = sessionFlowControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,6 +33,10 @@ public enum SpdyVersion {
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getMinorVersion() {
|
||||||
|
return minorVersion;
|
||||||
|
}
|
||||||
|
|
||||||
boolean useSessionFlowControl() {
|
boolean useSessionFlowControl() {
|
||||||
return sessionFlowControl;
|
return sessionFlowControl;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user