SPDY: update object hierarchy
This commit is contained in:
parent
0b4adc0889
commit
e279803587
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -22,11 +22,8 @@ import org.jboss.netty.util.internal.StringUtil;
|
|||||||
/**
|
/**
|
||||||
* The default {@link SpdyDataFrame} implementation.
|
* The default {@link SpdyDataFrame} implementation.
|
||||||
*/
|
*/
|
||||||
public class DefaultSpdyDataFrame implements SpdyDataFrame {
|
public class DefaultSpdyDataFrame extends DefaultSpdyStreamFrame implements SpdyDataFrame {
|
||||||
|
|
||||||
private int streamId;
|
|
||||||
private boolean last;
|
|
||||||
private boolean compressed;
|
|
||||||
private ChannelBuffer data = ChannelBuffers.EMPTY_BUFFER;
|
private ChannelBuffer data = ChannelBuffers.EMPTY_BUFFER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,47 +32,7 @@ public class DefaultSpdyDataFrame implements SpdyDataFrame {
|
|||||||
* @param streamId the Stream-ID of this frame
|
* @param streamId the Stream-ID of this frame
|
||||||
*/
|
*/
|
||||||
public DefaultSpdyDataFrame(int streamId) {
|
public DefaultSpdyDataFrame(int streamId) {
|
||||||
setStreamId(streamId);
|
super(streamId);
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public int getStreamID() {
|
|
||||||
return getStreamId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStreamId() {
|
|
||||||
return streamId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void setStreamID(int streamId) {
|
|
||||||
setStreamId(streamId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStreamId(int streamId) {
|
|
||||||
if (streamId <= 0) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Stream-ID must be positive: " + streamId);
|
|
||||||
}
|
|
||||||
this.streamId = streamId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLast() {
|
|
||||||
return last;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLast(boolean last) {
|
|
||||||
this.last = last;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public boolean isCompressed() {
|
|
||||||
return compressed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void setCompressed(boolean compressed) {
|
|
||||||
this.compressed = compressed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChannelBuffer getData() {
|
public ChannelBuffer getData() {
|
||||||
@ -99,15 +56,13 @@ public class DefaultSpdyDataFrame implements SpdyDataFrame {
|
|||||||
buf.append(getClass().getSimpleName());
|
buf.append(getClass().getSimpleName());
|
||||||
buf.append("(last: ");
|
buf.append("(last: ");
|
||||||
buf.append(isLast());
|
buf.append(isLast());
|
||||||
buf.append("; compressed: ");
|
|
||||||
buf.append(isCompressed());
|
|
||||||
buf.append(')');
|
buf.append(')');
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
buf.append("--> Stream-ID = ");
|
buf.append("--> Stream-ID = ");
|
||||||
buf.append(streamId);
|
buf.append(getStreamId());
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
buf.append("--> Size = ");
|
buf.append("--> Size = ");
|
||||||
buf.append(data.readableBytes());
|
buf.append(getData().readableBytes());
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -55,20 +55,10 @@ public class DefaultSpdyGoAwayFrame implements SpdyGoAwayFrame {
|
|||||||
setStatus(status);
|
setStatus(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public int getLastGoodStreamID() {
|
|
||||||
return getLastGoodStreamId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLastGoodStreamId() {
|
public int getLastGoodStreamId() {
|
||||||
return lastGoodStreamId;
|
return lastGoodStreamId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void setLastGoodStreamID(int lastGoodStreamId) {
|
|
||||||
setLastGoodStreamId(lastGoodStreamId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastGoodStreamId(int lastGoodStreamId) {
|
public void setLastGoodStreamId(int lastGoodStreamId) {
|
||||||
if (lastGoodStreamId < 0) {
|
if (lastGoodStreamId < 0) {
|
||||||
throw new IllegalArgumentException("Last-good-stream-ID"
|
throw new IllegalArgumentException("Last-good-stream-ID"
|
||||||
@ -91,10 +81,10 @@ public class DefaultSpdyGoAwayFrame implements SpdyGoAwayFrame {
|
|||||||
buf.append(getClass().getSimpleName());
|
buf.append(getClass().getSimpleName());
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
buf.append("--> Last-good-stream-ID = ");
|
buf.append("--> Last-good-stream-ID = ");
|
||||||
buf.append(lastGoodStreamId);
|
buf.append(getLastGoodStreamId());
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
buf.append("--> Status: ");
|
buf.append("--> Status: ");
|
||||||
buf.append(status.toString());
|
buf.append(getStatus().toString());
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,95 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012 The Netty Project
|
|
||||||
*
|
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package org.jboss.netty.handler.codec.spdy;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.jboss.netty.util.internal.StringUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The default {@link SpdyHeaderBlock} implementation.
|
|
||||||
*/
|
|
||||||
public class DefaultSpdyHeaderBlock implements SpdyHeaderBlock {
|
|
||||||
|
|
||||||
private boolean invalid;
|
|
||||||
private final SpdyHeaders headers = new SpdyHeaders();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new instance.
|
|
||||||
*/
|
|
||||||
protected DefaultSpdyHeaderBlock() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInvalid() {
|
|
||||||
return invalid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInvalid() {
|
|
||||||
invalid = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addHeader(final String name, final Object value) {
|
|
||||||
headers.addHeader(name, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHeader(final String name, final Object value) {
|
|
||||||
headers.setHeader(name, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHeader(final String name, final Iterable<?> values) {
|
|
||||||
headers.setHeader(name, values);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeHeader(final String name) {
|
|
||||||
headers.removeHeader(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearHeaders() {
|
|
||||||
headers.clearHeaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHeader(final String name) {
|
|
||||||
return headers.getHeader(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getHeaders(final String name) {
|
|
||||||
return headers.getHeaders(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Map.Entry<String, String>> getHeaders() {
|
|
||||||
return headers.getHeaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean containsHeader(final String name) {
|
|
||||||
return headers.containsHeader(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getHeaderNames() {
|
|
||||||
return headers.getHeaderNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void appendHeaders(StringBuilder buf) {
|
|
||||||
for (Map.Entry<String, String> e: getHeaders()) {
|
|
||||||
buf.append(" ");
|
|
||||||
buf.append(e.getKey());
|
|
||||||
buf.append(": ");
|
|
||||||
buf.append(e.getValue());
|
|
||||||
buf.append(StringUtil.NEWLINE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -15,17 +15,20 @@
|
|||||||
*/
|
*/
|
||||||
package org.jboss.netty.handler.codec.spdy;
|
package org.jboss.netty.handler.codec.spdy;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jboss.netty.util.internal.StringUtil;
|
import org.jboss.netty.util.internal.StringUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default {@link SpdyHeadersFrame} implementation.
|
* The default {@link SpdyHeadersFrame} implementation.
|
||||||
*/
|
*/
|
||||||
public class DefaultSpdyHeadersFrame extends DefaultSpdyHeaderBlock
|
public class DefaultSpdyHeadersFrame extends DefaultSpdyStreamFrame
|
||||||
implements SpdyHeadersFrame {
|
implements SpdyHeadersFrame {
|
||||||
|
|
||||||
private int streamId;
|
private boolean invalid;
|
||||||
private boolean last;
|
private final SpdyHeaders headers = new SpdyHeaders();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
@ -33,37 +36,55 @@ public class DefaultSpdyHeadersFrame extends DefaultSpdyHeaderBlock
|
|||||||
* @param streamId the Stream-ID of this frame
|
* @param streamId the Stream-ID of this frame
|
||||||
*/
|
*/
|
||||||
public DefaultSpdyHeadersFrame(int streamId) {
|
public DefaultSpdyHeadersFrame(int streamId) {
|
||||||
setStreamId(streamId);
|
super(streamId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
public boolean isInvalid() {
|
||||||
public int getStreamID() {
|
return invalid;
|
||||||
return getStreamId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStreamId() {
|
public void setInvalid() {
|
||||||
return streamId;
|
invalid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
public void addHeader(final String name, final Object value) {
|
||||||
public void setStreamID(int streamId) {
|
headers.addHeader(name, value);
|
||||||
setStreamId(streamId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStreamId(int streamId) {
|
public void setHeader(final String name, final Object value) {
|
||||||
if (streamId <= 0) {
|
headers.setHeader(name, value);
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Stream-ID must be positive: " + streamId);
|
|
||||||
}
|
|
||||||
this.streamId = streamId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLast() {
|
public void setHeader(final String name, final Iterable<?> values) {
|
||||||
return last;
|
headers.setHeader(name, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLast(boolean last) {
|
public void removeHeader(final String name) {
|
||||||
this.last = last;
|
headers.removeHeader(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearHeaders() {
|
||||||
|
headers.clearHeaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHeader(final String name) {
|
||||||
|
return headers.getHeader(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getHeaders(final String name) {
|
||||||
|
return headers.getHeaders(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Map.Entry<String, String>> getHeaders() {
|
||||||
|
return headers.getHeaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean containsHeader(final String name) {
|
||||||
|
return headers.containsHeader(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getHeaderNames() {
|
||||||
|
return headers.getHeaderNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -75,7 +96,7 @@ public class DefaultSpdyHeadersFrame extends DefaultSpdyHeaderBlock
|
|||||||
buf.append(')');
|
buf.append(')');
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
buf.append("--> Stream-ID = ");
|
buf.append("--> Stream-ID = ");
|
||||||
buf.append(streamId);
|
buf.append(getStreamId());
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
buf.append("--> Headers:");
|
buf.append("--> Headers:");
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
@ -85,4 +106,14 @@ public class DefaultSpdyHeadersFrame extends DefaultSpdyHeaderBlock
|
|||||||
buf.setLength(buf.length() - StringUtil.NEWLINE.length());
|
buf.setLength(buf.length() - StringUtil.NEWLINE.length());
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void appendHeaders(StringBuilder buf) {
|
||||||
|
for (Map.Entry<String, String> e: getHeaders()) {
|
||||||
|
buf.append(" ");
|
||||||
|
buf.append(e.getKey());
|
||||||
|
buf.append(": ");
|
||||||
|
buf.append(e.getValue());
|
||||||
|
buf.append(StringUtil.NEWLINE);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -33,20 +33,10 @@ public class DefaultSpdyPingFrame implements SpdyPingFrame {
|
|||||||
setId(id);
|
setId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public int getID() {
|
|
||||||
return getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void setID(int id) {
|
|
||||||
setId(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(int id) {
|
public void setId(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
@ -57,7 +47,7 @@ public class DefaultSpdyPingFrame implements SpdyPingFrame {
|
|||||||
buf.append(getClass().getSimpleName());
|
buf.append(getClass().getSimpleName());
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
buf.append("--> ID = ");
|
buf.append("--> ID = ");
|
||||||
buf.append(id);
|
buf.append(getId());
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -20,9 +20,9 @@ import org.jboss.netty.util.internal.StringUtil;
|
|||||||
/**
|
/**
|
||||||
* The default {@link SpdyRstStreamFrame} implementation.
|
* The default {@link SpdyRstStreamFrame} implementation.
|
||||||
*/
|
*/
|
||||||
public class DefaultSpdyRstStreamFrame implements SpdyRstStreamFrame {
|
public class DefaultSpdyRstStreamFrame extends DefaultSpdyStreamFrame
|
||||||
|
implements SpdyRstStreamFrame {
|
||||||
|
|
||||||
private int streamId;
|
|
||||||
private SpdyStreamStatus status;
|
private SpdyStreamStatus status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,32 +42,10 @@ public class DefaultSpdyRstStreamFrame implements SpdyRstStreamFrame {
|
|||||||
* @param status the status of this frame
|
* @param status the status of this frame
|
||||||
*/
|
*/
|
||||||
public DefaultSpdyRstStreamFrame(int streamId, SpdyStreamStatus status) {
|
public DefaultSpdyRstStreamFrame(int streamId, SpdyStreamStatus status) {
|
||||||
setStreamId(streamId);
|
super(streamId);
|
||||||
setStatus(status);
|
setStatus(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public int getStreamID() {
|
|
||||||
return getStreamId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStreamId() {
|
|
||||||
return streamId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void setStreamID(int streamId) {
|
|
||||||
setStreamId(streamId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStreamId(int streamId) {
|
|
||||||
if (streamId <= 0) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Stream-ID must be positive: " + streamId);
|
|
||||||
}
|
|
||||||
this.streamId = streamId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SpdyStreamStatus getStatus() {
|
public SpdyStreamStatus getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -82,10 +60,10 @@ public class DefaultSpdyRstStreamFrame implements SpdyRstStreamFrame {
|
|||||||
buf.append(getClass().getSimpleName());
|
buf.append(getClass().getSimpleName());
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
buf.append("--> Stream-ID = ");
|
buf.append("--> Stream-ID = ");
|
||||||
buf.append(streamId);
|
buf.append(getStreamId());
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
buf.append("--> Status: ");
|
buf.append("--> Status: ");
|
||||||
buf.append(status.toString());
|
buf.append(getStatus().toString());
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -29,11 +29,6 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
|||||||
private boolean clear;
|
private boolean clear;
|
||||||
private final Map<Integer, Setting> settingsMap = new TreeMap<Integer, Setting>();
|
private final Map<Integer, Setting> settingsMap = new TreeMap<Integer, Setting>();
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public Set<Integer> getIDs() {
|
|
||||||
return getIds();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Integer> getIds() {
|
public Set<Integer> getIds() {
|
||||||
return settingsMap.keySet();
|
return settingsMap.keySet();
|
||||||
}
|
}
|
||||||
@ -78,11 +73,6 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public boolean persistValue(int id) {
|
|
||||||
return isPersistValue(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPersistValue(int id) {
|
public boolean isPersistValue(int id) {
|
||||||
Integer key = id;
|
Integer key = id;
|
||||||
if (settingsMap.containsKey(key)) {
|
if (settingsMap.containsKey(key)) {
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013 The Netty Project
|
||||||
|
*
|
||||||
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at:
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jboss.netty.handler.codec.spdy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default {@link SpdyStreamFrame} implementation.
|
||||||
|
*/
|
||||||
|
public abstract class DefaultSpdyStreamFrame implements SpdyStreamFrame {
|
||||||
|
|
||||||
|
private int streamId;
|
||||||
|
private boolean last;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance.
|
||||||
|
*
|
||||||
|
* @param streamId the Stream-ID of this frame
|
||||||
|
*/
|
||||||
|
protected DefaultSpdyStreamFrame(int streamId) {
|
||||||
|
setStreamId(streamId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStreamId() {
|
||||||
|
return streamId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStreamId(int streamId) {
|
||||||
|
if (streamId <= 0) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"Stream-ID must be positive: " + streamId);
|
||||||
|
}
|
||||||
|
this.streamId = streamId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLast() {
|
||||||
|
return last;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLast(boolean last) {
|
||||||
|
this.last = last;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -20,49 +20,16 @@ import org.jboss.netty.util.internal.StringUtil;
|
|||||||
/**
|
/**
|
||||||
* The default {@link SpdySynReplyFrame} implementation.
|
* The default {@link SpdySynReplyFrame} implementation.
|
||||||
*/
|
*/
|
||||||
public class DefaultSpdySynReplyFrame extends DefaultSpdyHeaderBlock
|
public class DefaultSpdySynReplyFrame extends DefaultSpdyHeadersFrame
|
||||||
implements SpdySynReplyFrame {
|
implements SpdySynReplyFrame {
|
||||||
|
|
||||||
private int streamId;
|
|
||||||
private boolean last;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
*
|
*
|
||||||
* @param streamId the Stream-ID of this frame
|
* @param streamId the Stream-ID of this frame
|
||||||
*/
|
*/
|
||||||
public DefaultSpdySynReplyFrame(int streamId) {
|
public DefaultSpdySynReplyFrame(int streamId) {
|
||||||
setStreamId(streamId);
|
super(streamId);
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public int getStreamID() {
|
|
||||||
return getStreamId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStreamId() {
|
|
||||||
return streamId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void setStreamID(int streamId) {
|
|
||||||
setStreamId(streamId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStreamId(int streamId) {
|
|
||||||
if (streamId <= 0) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Stream-ID must be positive: " + streamId);
|
|
||||||
}
|
|
||||||
this.streamId = streamId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLast() {
|
|
||||||
return last;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLast(boolean last) {
|
|
||||||
this.last = last;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -74,7 +41,7 @@ public class DefaultSpdySynReplyFrame extends DefaultSpdyHeaderBlock
|
|||||||
buf.append(')');
|
buf.append(')');
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
buf.append("--> Stream-ID = ");
|
buf.append("--> Stream-ID = ");
|
||||||
buf.append(streamId);
|
buf.append(getStreamId());
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
buf.append("--> Headers:");
|
buf.append("--> Headers:");
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -20,65 +20,31 @@ import org.jboss.netty.util.internal.StringUtil;
|
|||||||
/**
|
/**
|
||||||
* The default {@link SpdySynStreamFrame} implementation.
|
* The default {@link SpdySynStreamFrame} implementation.
|
||||||
*/
|
*/
|
||||||
public class DefaultSpdySynStreamFrame extends DefaultSpdyHeaderBlock
|
public class DefaultSpdySynStreamFrame extends DefaultSpdyHeadersFrame
|
||||||
implements SpdySynStreamFrame {
|
implements SpdySynStreamFrame {
|
||||||
|
|
||||||
private int streamId;
|
|
||||||
private int associatedToStreamId;
|
private int associatedToStreamId;
|
||||||
private byte priority;
|
private byte priority;
|
||||||
private boolean last;
|
|
||||||
private boolean unidirectional;
|
private boolean unidirectional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
*
|
*
|
||||||
* @param streamID the Stream-ID of this frame
|
* @param streamId the Stream-ID of this frame
|
||||||
* @param associatedToStreamId the Associated-To-Stream-ID of this frame
|
* @param associatedToStreamId the Associated-To-Stream-ID of this frame
|
||||||
* @param priority the priority of the stream
|
* @param priority the priority of the stream
|
||||||
*/
|
*/
|
||||||
public DefaultSpdySynStreamFrame(
|
public DefaultSpdySynStreamFrame(
|
||||||
int streamID, int associatedToStreamId, byte priority) {
|
int streamId, int associatedToStreamId, byte priority) {
|
||||||
setStreamId(streamID);
|
super(streamId);
|
||||||
setAssociatedToStreamId(associatedToStreamId);
|
setAssociatedToStreamId(associatedToStreamId);
|
||||||
setPriority(priority);
|
setPriority(priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public int getStreamID() {
|
|
||||||
return getStreamId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStreamId() {
|
|
||||||
return streamId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void setStreamID(int streamId) {
|
|
||||||
setStreamId(streamId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStreamId(int streamId) {
|
|
||||||
if (streamId <= 0) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Stream-ID must be positive: " + streamId);
|
|
||||||
}
|
|
||||||
this.streamId = streamId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public int getAssociatedToStreamID() {
|
|
||||||
return getAssociatedToStreamId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAssociatedToStreamId() {
|
public int getAssociatedToStreamId() {
|
||||||
return associatedToStreamId;
|
return associatedToStreamId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void setAssociatedToStreamID(int associatedToStreamId) {
|
|
||||||
setAssociatedToStreamId(associatedToStreamId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAssociatedToStreamId(int associatedToStreamId) {
|
public void setAssociatedToStreamId(int associatedToStreamId) {
|
||||||
if (associatedToStreamId < 0) {
|
if (associatedToStreamId < 0) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
@ -100,14 +66,6 @@ public class DefaultSpdySynStreamFrame extends DefaultSpdyHeaderBlock
|
|||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLast() {
|
|
||||||
return last;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLast(boolean last) {
|
|
||||||
this.last = last;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isUnidirectional() {
|
public boolean isUnidirectional() {
|
||||||
return unidirectional;
|
return unidirectional;
|
||||||
}
|
}
|
||||||
@ -127,15 +85,15 @@ public class DefaultSpdySynStreamFrame extends DefaultSpdyHeaderBlock
|
|||||||
buf.append(')');
|
buf.append(')');
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
buf.append("--> Stream-ID = ");
|
buf.append("--> Stream-ID = ");
|
||||||
buf.append(streamId);
|
buf.append(getStreamId());
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
if (associatedToStreamId != 0) {
|
if (associatedToStreamId != 0) {
|
||||||
buf.append("--> Associated-To-Stream-ID = ");
|
buf.append("--> Associated-To-Stream-ID = ");
|
||||||
buf.append(associatedToStreamId);
|
buf.append(getAssociatedToStreamId());
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
}
|
}
|
||||||
buf.append("--> Priority = ");
|
buf.append("--> Priority = ");
|
||||||
buf.append(priority);
|
buf.append(getPriority());
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
buf.append("--> Headers:");
|
buf.append("--> Headers:");
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -36,24 +36,14 @@ public class DefaultSpdyWindowUpdateFrame implements SpdyWindowUpdateFrame {
|
|||||||
setDeltaWindowSize(deltaWindowSize);
|
setDeltaWindowSize(deltaWindowSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public int getStreamID() {
|
|
||||||
return getStreamId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStreamId() {
|
public int getStreamId() {
|
||||||
return streamId;
|
return streamId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void setStreamID(int streamId) {
|
|
||||||
setStreamId(streamId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStreamId(int streamId) {
|
public void setStreamId(int streamId) {
|
||||||
if (streamId <= 0) {
|
if (streamId < 0) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Stream-ID must be positive: " + streamId);
|
"Stream-ID cannot be negative: " + streamId);
|
||||||
}
|
}
|
||||||
this.streamId = streamId;
|
this.streamId = streamId;
|
||||||
}
|
}
|
||||||
@ -77,10 +67,10 @@ public class DefaultSpdyWindowUpdateFrame implements SpdyWindowUpdateFrame {
|
|||||||
buf.append(getClass().getSimpleName());
|
buf.append(getClass().getSimpleName());
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
buf.append("--> Stream-ID = ");
|
buf.append("--> Stream-ID = ");
|
||||||
buf.append(streamId);
|
buf.append(getStreamId());
|
||||||
buf.append(StringUtil.NEWLINE);
|
buf.append(StringUtil.NEWLINE);
|
||||||
buf.append("--> Delta-Window-Size = ");
|
buf.append("--> Delta-Window-Size = ");
|
||||||
buf.append(deltaWindowSize);
|
buf.append(getDeltaWindowSize());
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -19,54 +19,9 @@ import org.jboss.netty.buffer.ChannelBuffer;
|
|||||||
import org.jboss.netty.buffer.ChannelBuffers;
|
import org.jboss.netty.buffer.ChannelBuffers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A SPDY Protocol Data Frame
|
* A SPDY Protocol DATA Frame
|
||||||
*/
|
*/
|
||||||
public interface SpdyDataFrame {
|
public interface SpdyDataFrame extends SpdyStreamFrame {
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #getStreamId()} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
int getStreamID();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the Stream-ID of this frame.
|
|
||||||
*/
|
|
||||||
int getStreamId();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #setStreamId(int)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
void setStreamID(int streamID);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the Stream-ID of this frame. The Stream-ID must be positive.
|
|
||||||
*/
|
|
||||||
void setStreamId(int streamID);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns {@code true} if this frame is the last frame to be transmitted
|
|
||||||
* on the stream.
|
|
||||||
*/
|
|
||||||
boolean isLast();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets if this frame is the last frame to be transmitted on the stream.
|
|
||||||
*/
|
|
||||||
void setLast(boolean last);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Removed from SPDY specification.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
boolean isCompressed();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Removed from SPDY specification.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
void setCompressed(boolean compressed);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the data payload of this frame. If there is no data payload
|
* Returns the data payload of this frame. If there is no data payload
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -16,8 +16,8 @@
|
|||||||
package org.jboss.netty.handler.codec.spdy;
|
package org.jboss.netty.handler.codec.spdy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A SPDY Protocol NOOP Control Frame
|
* A SPDY Protocol Frame
|
||||||
*/
|
*/
|
||||||
public interface SpdyNoOpFrame {
|
public interface SpdyFrame {
|
||||||
// Tag interface
|
// Tag interface
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -31,17 +31,6 @@ public class SpdyFrameCodec implements ChannelUpstreamHandler,
|
|||||||
private final SpdyFrameDecoder decoder;
|
private final SpdyFrameDecoder decoder;
|
||||||
private final SpdyFrameEncoder encoder;
|
private final SpdyFrameEncoder encoder;
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new instance with the default decoder and encoder options
|
|
||||||
* ({@code version (2)}, {@code maxChunkSize (8192)},
|
|
||||||
* {@code maxHeaderSize (16384)}, {@code compressionLevel (6)},
|
|
||||||
* {@code windowBits (15)}, and {@code memLevel (8)}).
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public SpdyFrameCodec() {
|
|
||||||
this(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance with the specified {@code version} and
|
* Creates a new instance with the specified {@code version} and
|
||||||
* the default decoder and encoder options
|
* the default decoder and encoder options
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -26,7 +26,7 @@ import org.jboss.netty.handler.codec.frame.FrameDecoder;
|
|||||||
import org.jboss.netty.handler.codec.frame.TooLongFrameException;
|
import org.jboss.netty.handler.codec.frame.TooLongFrameException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes {@link ChannelBuffer}s into SPDY Data and Control Frames.
|
* Decodes {@link ChannelBuffer}s into SPDY Frames.
|
||||||
*/
|
*/
|
||||||
public class SpdyFrameDecoder extends FrameDecoder {
|
public class SpdyFrameDecoder extends FrameDecoder {
|
||||||
|
|
||||||
@ -38,14 +38,14 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
|
|
||||||
private State state;
|
private State state;
|
||||||
private SpdySettingsFrame spdySettingsFrame;
|
private SpdySettingsFrame spdySettingsFrame;
|
||||||
private SpdyHeaderBlock spdyHeaderBlock;
|
private SpdyHeadersFrame spdyHeadersFrame;
|
||||||
|
|
||||||
// SPDY common header fields
|
// SPDY common header fields
|
||||||
private byte flags;
|
private byte flags;
|
||||||
private int length;
|
private int length;
|
||||||
private int version;
|
private int version;
|
||||||
private int type;
|
private int type;
|
||||||
private int streamID;
|
private int streamId;
|
||||||
|
|
||||||
// Header block decoding fields
|
// Header block decoding fields
|
||||||
private int headerSize;
|
private int headerSize;
|
||||||
@ -63,15 +63,6 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
FRAME_ERROR
|
FRAME_ERROR
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new instance with the default {@code version (2)},
|
|
||||||
* {@code maxChunkSize (8192)}, and {@code maxHeaderSize (16384)}.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public SpdyFrameDecoder() {
|
|
||||||
this(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance with the specified {@code version} and the default
|
* Creates a new instance with the specified {@code version} and the default
|
||||||
* {@code maxChunkSize (8192)} and {@code maxHeaderSize (16384)}.
|
* {@code maxChunkSize (8192)} and {@code maxHeaderSize (16384)}.
|
||||||
@ -134,13 +125,13 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
// All length 0 frames must be generated now
|
// All length 0 frames must be generated now
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
if (state == State.READ_DATA_FRAME) {
|
if (state == State.READ_DATA_FRAME) {
|
||||||
if (streamID == 0) {
|
if (streamId == 0) {
|
||||||
state = State.FRAME_ERROR;
|
state = State.FRAME_ERROR;
|
||||||
fireProtocolException(ctx, "Received invalid data frame");
|
fireProtocolException(ctx, "Received invalid data frame");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpdyDataFrame spdyDataFrame = new DefaultSpdyDataFrame(streamID);
|
SpdyDataFrame spdyDataFrame = new DefaultSpdyDataFrame(streamId);
|
||||||
spdyDataFrame.setLast((flags & SPDY_DATA_FLAG_FIN) != 0);
|
spdyDataFrame.setLast((flags & SPDY_DATA_FLAG_FIN) != 0);
|
||||||
state = State.READ_COMMON_HEADER;
|
state = State.READ_COMMON_HEADER;
|
||||||
return spdyDataFrame;
|
return spdyDataFrame;
|
||||||
@ -233,12 +224,12 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
|
|
||||||
case READ_HEADER_BLOCK_FRAME:
|
case READ_HEADER_BLOCK_FRAME:
|
||||||
try {
|
try {
|
||||||
spdyHeaderBlock = readHeaderBlockFrame(buffer);
|
spdyHeadersFrame = readHeaderBlockFrame(buffer);
|
||||||
if (spdyHeaderBlock != null) {
|
if (spdyHeadersFrame != null) {
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
state = State.READ_COMMON_HEADER;
|
state = State.READ_COMMON_HEADER;
|
||||||
Object frame = spdyHeaderBlock;
|
Object frame = spdyHeadersFrame;
|
||||||
spdyHeaderBlock = null;
|
spdyHeadersFrame = null;
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
state = State.READ_HEADER_BLOCK;
|
state = State.READ_HEADER_BLOCK;
|
||||||
@ -258,15 +249,15 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
decodeHeaderBlock(buffer.readSlice(compressedBytes));
|
decodeHeaderBlock(buffer.readSlice(compressedBytes));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
state = State.FRAME_ERROR;
|
state = State.FRAME_ERROR;
|
||||||
spdyHeaderBlock = null;
|
spdyHeadersFrame = null;
|
||||||
decompressed = null;
|
decompressed = null;
|
||||||
Channels.fireExceptionCaught(ctx, e);
|
Channels.fireExceptionCaught(ctx, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spdyHeaderBlock != null && spdyHeaderBlock.isInvalid()) {
|
if (spdyHeadersFrame != null && spdyHeadersFrame.isInvalid()) {
|
||||||
Object frame = spdyHeaderBlock;
|
Object frame = spdyHeadersFrame;
|
||||||
spdyHeaderBlock = null;
|
spdyHeadersFrame = null;
|
||||||
decompressed = null;
|
decompressed = null;
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
state = State.READ_COMMON_HEADER;
|
state = State.READ_COMMON_HEADER;
|
||||||
@ -275,15 +266,15 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
Object frame = spdyHeaderBlock;
|
Object frame = spdyHeadersFrame;
|
||||||
spdyHeaderBlock = null;
|
spdyHeadersFrame = null;
|
||||||
state = State.READ_COMMON_HEADER;
|
state = State.READ_COMMON_HEADER;
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
case READ_DATA_FRAME:
|
case READ_DATA_FRAME:
|
||||||
if (streamID == 0) {
|
if (streamId == 0) {
|
||||||
state = State.FRAME_ERROR;
|
state = State.FRAME_ERROR;
|
||||||
fireProtocolException(ctx, "Received invalid data frame");
|
fireProtocolException(ctx, "Received invalid data frame");
|
||||||
return null;
|
return null;
|
||||||
@ -297,7 +288,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpdyDataFrame spdyDataFrame = new DefaultSpdyDataFrame(streamID);
|
SpdyDataFrame spdyDataFrame = new DefaultSpdyDataFrame(streamId);
|
||||||
spdyDataFrame.setData(buffer.readBytes(dataLength));
|
spdyDataFrame.setData(buffer.readBytes(dataLength));
|
||||||
length -= dataLength;
|
length -= dataLength;
|
||||||
|
|
||||||
@ -378,14 +369,14 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
return nextState;
|
return nextState;
|
||||||
} else {
|
} else {
|
||||||
// Decode data frame common header
|
// Decode data frame common header
|
||||||
streamID = getUnsignedInt(buffer, frameOffset);
|
streamId = getUnsignedInt(buffer, frameOffset);
|
||||||
|
|
||||||
return State.READ_DATA_FRAME;
|
return State.READ_DATA_FRAME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object readControlFrame(ChannelBuffer buffer) {
|
private Object readControlFrame(ChannelBuffer buffer) {
|
||||||
int streamID;
|
int streamId;
|
||||||
int statusCode;
|
int statusCode;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SPDY_RST_STREAM_FRAME:
|
case SPDY_RST_STREAM_FRAME:
|
||||||
@ -393,11 +384,11 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
streamID = getUnsignedInt(buffer, buffer.readerIndex());
|
streamId = getUnsignedInt(buffer, buffer.readerIndex());
|
||||||
statusCode = getSignedInt(buffer, buffer.readerIndex() + 4);
|
statusCode = getSignedInt(buffer, buffer.readerIndex() + 4);
|
||||||
buffer.skipBytes(8);
|
buffer.skipBytes(8);
|
||||||
|
|
||||||
return new DefaultSpdyRstStreamFrame(streamID, statusCode);
|
return new DefaultSpdyRstStreamFrame(streamId, statusCode);
|
||||||
|
|
||||||
case SPDY_PING_FRAME:
|
case SPDY_PING_FRAME:
|
||||||
if (buffer.readableBytes() < 4) {
|
if (buffer.readableBytes() < 4) {
|
||||||
@ -432,20 +423,20 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
streamID = getUnsignedInt(buffer, buffer.readerIndex());
|
streamId = getUnsignedInt(buffer, buffer.readerIndex());
|
||||||
int deltaWindowSize = getUnsignedInt(buffer, buffer.readerIndex() + 4);
|
int deltaWindowSize = getUnsignedInt(buffer, buffer.readerIndex() + 4);
|
||||||
buffer.skipBytes(8);
|
buffer.skipBytes(8);
|
||||||
|
|
||||||
return new DefaultSpdyWindowUpdateFrame(streamID, deltaWindowSize);
|
return new DefaultSpdyWindowUpdateFrame(streamId, deltaWindowSize);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error("Shouldn't reach here.");
|
throw new Error("Shouldn't reach here.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SpdyHeaderBlock readHeaderBlockFrame(ChannelBuffer buffer) {
|
private SpdyHeadersFrame readHeaderBlockFrame(ChannelBuffer buffer) {
|
||||||
int minLength;
|
int minLength;
|
||||||
int streamID;
|
int streamId;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SPDY_SYN_STREAM_FRAME:
|
case SPDY_SYN_STREAM_FRAME:
|
||||||
minLength = version < 3 ? 12 : 10;
|
minLength = version < 3 ? 12 : 10;
|
||||||
@ -454,7 +445,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int offset = buffer.readerIndex();
|
int offset = buffer.readerIndex();
|
||||||
streamID = getUnsignedInt(buffer, offset);
|
streamId = getUnsignedInt(buffer, offset);
|
||||||
int associatedToStreamID = getUnsignedInt(buffer, offset + 4);
|
int associatedToStreamID = getUnsignedInt(buffer, offset + 4);
|
||||||
byte priority = (byte) (buffer.getByte(offset + 8) >> 5 & 0x07);
|
byte priority = (byte) (buffer.getByte(offset + 8) >> 5 & 0x07);
|
||||||
if (version < 3) {
|
if (version < 3) {
|
||||||
@ -470,7 +461,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SpdySynStreamFrame spdySynStreamFrame =
|
SpdySynStreamFrame spdySynStreamFrame =
|
||||||
new DefaultSpdySynStreamFrame(streamID, associatedToStreamID, priority);
|
new DefaultSpdySynStreamFrame(streamId, associatedToStreamID, priority);
|
||||||
spdySynStreamFrame.setLast((flags & SPDY_FLAG_FIN) != 0);
|
spdySynStreamFrame.setLast((flags & SPDY_FLAG_FIN) != 0);
|
||||||
spdySynStreamFrame.setUnidirectional((flags & SPDY_FLAG_UNIDIRECTIONAL) != 0);
|
spdySynStreamFrame.setUnidirectional((flags & SPDY_FLAG_UNIDIRECTIONAL) != 0);
|
||||||
|
|
||||||
@ -482,7 +473,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
streamID = getUnsignedInt(buffer, buffer.readerIndex());
|
streamId = getUnsignedInt(buffer, buffer.readerIndex());
|
||||||
buffer.skipBytes(4);
|
buffer.skipBytes(4);
|
||||||
length -= 4;
|
length -= 4;
|
||||||
|
|
||||||
@ -498,7 +489,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
length = 0;
|
length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpdySynReplyFrame spdySynReplyFrame = new DefaultSpdySynReplyFrame(streamID);
|
SpdySynReplyFrame spdySynReplyFrame = new DefaultSpdySynReplyFrame(streamId);
|
||||||
spdySynReplyFrame.setLast((flags & SPDY_FLAG_FIN) != 0);
|
spdySynReplyFrame.setLast((flags & SPDY_FLAG_FIN) != 0);
|
||||||
|
|
||||||
return spdySynReplyFrame;
|
return spdySynReplyFrame;
|
||||||
@ -513,7 +504,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
streamID = getUnsignedInt(buffer, buffer.readerIndex());
|
streamId = getUnsignedInt(buffer, buffer.readerIndex());
|
||||||
buffer.skipBytes(4);
|
buffer.skipBytes(4);
|
||||||
length -= 4;
|
length -= 4;
|
||||||
|
|
||||||
@ -529,7 +520,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
length = 0;
|
length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpdyHeadersFrame spdyHeadersFrame = new DefaultSpdyHeadersFrame(streamID);
|
SpdyHeadersFrame spdyHeadersFrame = new DefaultSpdyHeadersFrame(streamId);
|
||||||
spdyHeadersFrame.setLast((flags & SPDY_FLAG_FIN) != 0);
|
spdyHeadersFrame.setLast((flags & SPDY_FLAG_FIN) != 0);
|
||||||
|
|
||||||
return spdyHeadersFrame;
|
return spdyHeadersFrame;
|
||||||
@ -574,7 +565,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
headerBlockDecompressor.setInput(buffer);
|
headerBlockDecompressor.setInput(buffer);
|
||||||
headerBlockDecompressor.decode(decompressed);
|
headerBlockDecompressor.decode(decompressed);
|
||||||
|
|
||||||
if (spdyHeaderBlock == null) {
|
if (spdyHeadersFrame == null) {
|
||||||
// Only decompressing data to keep decompression context in sync
|
// Only decompressing data to keep decompression context in sync
|
||||||
decompressed = null;
|
decompressed = null;
|
||||||
return;
|
return;
|
||||||
@ -589,7 +580,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
}
|
}
|
||||||
numHeaders = readLengthField();
|
numHeaders = readLengthField();
|
||||||
if (numHeaders < 0) {
|
if (numHeaders < 0) {
|
||||||
spdyHeaderBlock.setInvalid();
|
spdyHeadersFrame.setInvalid();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -608,7 +599,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
|
|
||||||
// Recipients of a zero-length name must issue a stream error
|
// Recipients of a zero-length name must issue a stream error
|
||||||
if (nameLength <= 0) {
|
if (nameLength <= 0) {
|
||||||
spdyHeaderBlock.setInvalid();
|
spdyHeadersFrame.setInvalid();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
headerSize += nameLength;
|
headerSize += nameLength;
|
||||||
@ -628,8 +619,8 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
String name = new String(nameBytes, "UTF-8");
|
String name = new String(nameBytes, "UTF-8");
|
||||||
|
|
||||||
// Check for identically named headers
|
// Check for identically named headers
|
||||||
if (spdyHeaderBlock.containsHeader(name)) {
|
if (spdyHeadersFrame.containsHeader(name)) {
|
||||||
spdyHeaderBlock.setInvalid();
|
spdyHeadersFrame.setInvalid();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -643,17 +634,17 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
|
|
||||||
// Recipients of illegal value fields must issue a stream error
|
// Recipients of illegal value fields must issue a stream error
|
||||||
if (valueLength < 0) {
|
if (valueLength < 0) {
|
||||||
spdyHeaderBlock.setInvalid();
|
spdyHeadersFrame.setInvalid();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SPDY/3 allows zero-length (empty) header values
|
// SPDY/3 allows zero-length (empty) header values
|
||||||
if (valueLength == 0) {
|
if (valueLength == 0) {
|
||||||
if (version < 3) {
|
if (version < 3) {
|
||||||
spdyHeaderBlock.setInvalid();
|
spdyHeadersFrame.setInvalid();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
spdyHeaderBlock.addHeader(name, "");
|
spdyHeadersFrame.addHeader(name, "");
|
||||||
numHeaders --;
|
numHeaders --;
|
||||||
this.headerSize = headerSize;
|
this.headerSize = headerSize;
|
||||||
continue;
|
continue;
|
||||||
@ -685,16 +676,16 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
|||||||
if (index < valueBytes.length && valueBytes[index + 1] == (byte) 0) {
|
if (index < valueBytes.length && valueBytes[index + 1] == (byte) 0) {
|
||||||
// Received multiple, in-sequence NULL characters
|
// Received multiple, in-sequence NULL characters
|
||||||
// Recipients of illegal value fields must issue a stream error
|
// Recipients of illegal value fields must issue a stream error
|
||||||
spdyHeaderBlock.setInvalid();
|
spdyHeadersFrame.setInvalid();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String value = new String(valueBytes, offset, index - offset, "UTF-8");
|
String value = new String(valueBytes, offset, index - offset, "UTF-8");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
spdyHeaderBlock.addHeader(name, value);
|
spdyHeadersFrame.addHeader(name, value);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
// Name contains NULL or non-ascii characters
|
// Name contains NULL or non-ascii characters
|
||||||
spdyHeaderBlock.setInvalid();
|
spdyHeadersFrame.setInvalid();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
index ++;
|
index ++;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -30,7 +30,7 @@ import java.util.Set;
|
|||||||
import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*;
|
import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes a SPDY Data or Control Frame into a {@link ChannelBuffer}.
|
* Encodes a SPDY Frame into a {@link ChannelBuffer}.
|
||||||
*/
|
*/
|
||||||
public class SpdyFrameEncoder implements ChannelDownstreamHandler {
|
public class SpdyFrameEncoder implements ChannelDownstreamHandler {
|
||||||
|
|
||||||
@ -38,16 +38,6 @@ public class SpdyFrameEncoder implements ChannelDownstreamHandler {
|
|||||||
private volatile boolean finished;
|
private volatile boolean finished;
|
||||||
private final SpdyHeaderBlockCompressor headerBlockCompressor;
|
private final SpdyHeaderBlockCompressor headerBlockCompressor;
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new instance with the default {@code version (2)},
|
|
||||||
* {@code compressionLevel (6)}, {@code windowBits (15)},
|
|
||||||
* and {@code memLevel (8)}.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public SpdyFrameEncoder() {
|
|
||||||
this(2, 6, 15, 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance with the specified {@code version} and the
|
* Creates a new instance with the specified {@code version} and the
|
||||||
* default {@code compressionLevel (6)}, {@code windowBits (15)},
|
* default {@code compressionLevel (6)}, {@code windowBits (15)},
|
||||||
@ -57,15 +47,6 @@ public class SpdyFrameEncoder implements ChannelDownstreamHandler {
|
|||||||
this(version, 6, 15, 8);
|
this(version, 6, 15, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new instance with the default {@code version (2)} and the
|
|
||||||
* specified parameters.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public SpdyFrameEncoder(int compressionLevel, int windowBits, int memLevel) {
|
|
||||||
this(2, compressionLevel, windowBits, memLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance with the specified parameters.
|
* Creates a new instance with the specified parameters.
|
||||||
*/
|
*/
|
||||||
@ -255,17 +236,6 @@ public class SpdyFrameEncoder implements ChannelDownstreamHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg instanceof SpdyNoOpFrame) {
|
|
||||||
|
|
||||||
ChannelBuffer frame = ChannelBuffers.buffer(
|
|
||||||
ByteOrder.BIG_ENDIAN, SPDY_HEADER_SIZE);
|
|
||||||
frame.writeShort(version | 0x8000);
|
|
||||||
frame.writeShort(SPDY_NOOP_FRAME);
|
|
||||||
frame.writeInt(0);
|
|
||||||
Channels.write(ctx, e.getFuture(), frame, e.getRemoteAddress());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg instanceof SpdyPingFrame) {
|
if (msg instanceof SpdyPingFrame) {
|
||||||
|
|
||||||
SpdyPingFrame spdyPingFrame = (SpdyPingFrame) msg;
|
SpdyPingFrame spdyPingFrame = (SpdyPingFrame) msg;
|
||||||
@ -360,7 +330,7 @@ public class SpdyFrameEncoder implements ChannelDownstreamHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ChannelBuffer encodeHeaderBlock(int version, SpdyHeaderBlock headerFrame)
|
private static ChannelBuffer encodeHeaderBlock(int version, SpdyHeadersFrame headerFrame)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Set<String> names = headerFrame.getHeaderNames();
|
Set<String> names = headerFrame.getHeaderNames();
|
||||||
int numHeaders = names.size();
|
int numHeaders = names.size();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -16,27 +16,15 @@
|
|||||||
package org.jboss.netty.handler.codec.spdy;
|
package org.jboss.netty.handler.codec.spdy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A SPDY Protocol GOAWAY Control Frame
|
* A SPDY Protocol GOAWAY Frame
|
||||||
*/
|
*/
|
||||||
public interface SpdyGoAwayFrame {
|
public interface SpdyGoAwayFrame extends SpdyFrame {
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #getLastGoodStreamId()} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
int getLastGoodStreamID();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Last-good-stream-ID of this frame.
|
* Returns the Last-good-stream-ID of this frame.
|
||||||
*/
|
*/
|
||||||
int getLastGoodStreamId();
|
int getLastGoodStreamId();
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #setLastGoodStreamId(int)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
void setLastGoodStreamID(int lastGoodStreamId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the Last-good-stream-ID of this frame. The Last-good-stream-ID
|
* Sets the Last-good-stream-ID of this frame. The Last-good-stream-ID
|
||||||
* cannot be negative.
|
* cannot be negative.
|
||||||
|
@ -1,103 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012 The Netty Project
|
|
||||||
*
|
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package org.jboss.netty.handler.codec.spdy;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A SPDY Name/Value Header Block which provides common properties for
|
|
||||||
* {@link SpdySynStreamFrame}, {@link SpdySynReplyFrame}, and
|
|
||||||
* {@link SpdyHeadersFrame}.
|
|
||||||
* @see SpdyHeaders
|
|
||||||
*/
|
|
||||||
public interface SpdyHeaderBlock {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns {@code true} if this header block is invalid.
|
|
||||||
* A RST_STREAM frame with code PROTOCOL_ERROR should be sent.
|
|
||||||
*/
|
|
||||||
boolean isInvalid();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Marks this header block as invalid.
|
|
||||||
*/
|
|
||||||
void setInvalid();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the header value with the specified header name. If there is
|
|
||||||
* more than one header value for the specified header name, the first
|
|
||||||
* value is returned.
|
|
||||||
*
|
|
||||||
* @return the header value or {@code null} if there is no such header
|
|
||||||
*/
|
|
||||||
String getHeader(String name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the header values with the specified header name.
|
|
||||||
*
|
|
||||||
* @return the {@link List} of header values. An empty list if there is no
|
|
||||||
* such header.
|
|
||||||
*/
|
|
||||||
List<String> getHeaders(String name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns all header names and values that this block contains.
|
|
||||||
*
|
|
||||||
* @return the {@link List} of the header name-value pairs. An empty list
|
|
||||||
* if there is no header in this message.
|
|
||||||
*/
|
|
||||||
List<Map.Entry<String, String>> getHeaders();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns {@code true} if and only if there is a header with the specified
|
|
||||||
* header name.
|
|
||||||
*/
|
|
||||||
boolean containsHeader(String name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the {@link Set} of all header names that this block contains.
|
|
||||||
*/
|
|
||||||
Set<String> getHeaderNames();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a new header with the specified name and value.
|
|
||||||
*/
|
|
||||||
void addHeader(String name, Object value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a new header with the specified name and value. If there is an
|
|
||||||
* existing header with the same name, the existing header is removed.
|
|
||||||
*/
|
|
||||||
void setHeader(String name, Object value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a new header with the specified name and values. If there is an
|
|
||||||
* existing header with the same name, the existing header is removed.
|
|
||||||
*/
|
|
||||||
void setHeader(String name, Iterable<?> values);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the header with the specified name.
|
|
||||||
*/
|
|
||||||
void removeHeader(String name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes all headers from this block.
|
|
||||||
*/
|
|
||||||
void clearHeaders();
|
|
||||||
}
|
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -27,7 +27,7 @@ import java.util.TreeSet;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the constants for the standard SPDY HTTP header names and commonly
|
* Provides the constants for the standard SPDY HTTP header names and commonly
|
||||||
* used utility methods that access a {@link SpdyHeaderBlock}.
|
* used utility methods that access a {@link SpdyHeadersFrame}.
|
||||||
* @apiviz.stereotype static
|
* @apiviz.stereotype static
|
||||||
*/
|
*/
|
||||||
public class SpdyHeaders {
|
public class SpdyHeaders {
|
||||||
@ -103,8 +103,8 @@ public class SpdyHeaders {
|
|||||||
*
|
*
|
||||||
* @return the header value or {@code null} if there is no such header
|
* @return the header value or {@code null} if there is no such header
|
||||||
*/
|
*/
|
||||||
public static String getHeader(SpdyHeaderBlock block, String name) {
|
public static String getHeader(SpdyHeadersFrame frame, String name) {
|
||||||
return block.getHeader(name);
|
return frame.getHeader(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -115,8 +115,8 @@ public class SpdyHeaders {
|
|||||||
* @return the header value or the {@code defaultValue} if there is no such
|
* @return the header value or the {@code defaultValue} if there is no such
|
||||||
* header
|
* header
|
||||||
*/
|
*/
|
||||||
public static String getHeader(SpdyHeaderBlock block, String name, String defaultValue) {
|
public static String getHeader(SpdyHeadersFrame frame, String name, String defaultValue) {
|
||||||
String value = block.getHeader(name);
|
String value = frame.getHeader(name);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
@ -127,82 +127,66 @@ public class SpdyHeaders {
|
|||||||
* Sets a new header with the specified name and value. If there is an
|
* Sets a new header with the specified name and value. If there is an
|
||||||
* existing header with the same name, the existing header is removed.
|
* existing header with the same name, the existing header is removed.
|
||||||
*/
|
*/
|
||||||
public static void setHeader(SpdyHeaderBlock block, String name, Object value) {
|
public static void setHeader(SpdyHeadersFrame frame, String name, Object value) {
|
||||||
block.setHeader(name, value);
|
frame.setHeader(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a new header with the specified name and values. If there is an
|
* Sets a new header with the specified name and values. If there is an
|
||||||
* existing header with the same name, the existing header is removed.
|
* existing header with the same name, the existing header is removed.
|
||||||
*/
|
*/
|
||||||
public static void setHeader(SpdyHeaderBlock block, String name, Iterable<?> values) {
|
public static void setHeader(SpdyHeadersFrame frame, String name, Iterable<?> values) {
|
||||||
block.setHeader(name, values);
|
frame.setHeader(name, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new header with the specified name and value.
|
* Adds a new header with the specified name and value.
|
||||||
*/
|
*/
|
||||||
public static void addHeader(SpdyHeaderBlock block, String name, Object value) {
|
public static void addHeader(SpdyHeadersFrame frame, String name, Object value) {
|
||||||
block.addHeader(name, value);
|
frame.addHeader(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the SPDY host header.
|
* Removes the SPDY host header.
|
||||||
*/
|
*/
|
||||||
public static void removeHost(SpdyHeaderBlock block) {
|
public static void removeHost(SpdyHeadersFrame frame) {
|
||||||
block.removeHeader(HttpNames.HOST);
|
frame.removeHeader(HttpNames.HOST);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the SPDY host header.
|
* Returns the SPDY host header.
|
||||||
*/
|
*/
|
||||||
public static String getHost(SpdyHeaderBlock block) {
|
public static String getHost(SpdyHeadersFrame frame) {
|
||||||
return block.getHeader(HttpNames.HOST);
|
return frame.getHeader(HttpNames.HOST);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the SPDY host header.
|
* Set the SPDY host header.
|
||||||
*/
|
*/
|
||||||
public static void setHost(SpdyHeaderBlock block, String host) {
|
public static void setHost(SpdyHeadersFrame frame, String host) {
|
||||||
block.setHeader(HttpNames.HOST, host);
|
frame.setHeader(HttpNames.HOST, host);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the HTTP method header.
|
* Removes the HTTP method header.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static void removeMethod(int spdyVersion, SpdyHeadersFrame frame) {
|
||||||
public static void removeMethod(SpdyHeaderBlock block) {
|
|
||||||
removeMethod(2, block);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the HTTP method header.
|
|
||||||
*/
|
|
||||||
public static void removeMethod(int spdyVersion, SpdyHeaderBlock block) {
|
|
||||||
if (spdyVersion < 3) {
|
if (spdyVersion < 3) {
|
||||||
block.removeHeader(Spdy2HttpNames.METHOD);
|
frame.removeHeader(Spdy2HttpNames.METHOD);
|
||||||
} else {
|
} else {
|
||||||
block.removeHeader(HttpNames.METHOD);
|
frame.removeHeader(HttpNames.METHOD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link HttpMethod} represented by the HTTP method header.
|
* Returns the {@link HttpMethod} represented by the HTTP method header.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static HttpMethod getMethod(int spdyVersion, SpdyHeadersFrame frame) {
|
||||||
public static HttpMethod getMethod(SpdyHeaderBlock block) {
|
|
||||||
return getMethod(2, block);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the {@link HttpMethod} represented by the HTTP method header.
|
|
||||||
*/
|
|
||||||
public static HttpMethod getMethod(int spdyVersion, SpdyHeaderBlock block) {
|
|
||||||
try {
|
try {
|
||||||
if (spdyVersion < 3) {
|
if (spdyVersion < 3) {
|
||||||
return HttpMethod.valueOf(block.getHeader(Spdy2HttpNames.METHOD));
|
return HttpMethod.valueOf(frame.getHeader(Spdy2HttpNames.METHOD));
|
||||||
} else {
|
} else {
|
||||||
return HttpMethod.valueOf(block.getHeader(HttpNames.METHOD));
|
return HttpMethod.valueOf(frame.getHeader(HttpNames.METHOD));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
@ -212,116 +196,68 @@ public class SpdyHeaders {
|
|||||||
/**
|
/**
|
||||||
* Sets the HTTP method header.
|
* Sets the HTTP method header.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static void setMethod(int spdyVersion, SpdyHeadersFrame frame, HttpMethod method) {
|
||||||
public static void setMethod(SpdyHeaderBlock block, HttpMethod method) {
|
|
||||||
setMethod(2, block, method);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the HTTP method header.
|
|
||||||
*/
|
|
||||||
public static void setMethod(int spdyVersion, SpdyHeaderBlock block, HttpMethod method) {
|
|
||||||
if (spdyVersion < 3) {
|
if (spdyVersion < 3) {
|
||||||
block.setHeader(Spdy2HttpNames.METHOD, method.getName());
|
frame.setHeader(Spdy2HttpNames.METHOD, method.getName());
|
||||||
} else {
|
} else {
|
||||||
block.setHeader(HttpNames.METHOD, method.getName());
|
frame.setHeader(HttpNames.METHOD, method.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the URL scheme header.
|
* Removes the URL scheme header.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static void removeScheme(int spdyVersion, SpdyHeadersFrame frame) {
|
||||||
public static void removeScheme(SpdyHeaderBlock block) {
|
|
||||||
removeMethod(2, block);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the URL scheme header.
|
|
||||||
*/
|
|
||||||
public static void removeScheme(int spdyVersion, SpdyHeaderBlock block) {
|
|
||||||
if (spdyVersion < 2) {
|
if (spdyVersion < 2) {
|
||||||
block.removeHeader(Spdy2HttpNames.SCHEME);
|
frame.removeHeader(Spdy2HttpNames.SCHEME);
|
||||||
} else {
|
} else {
|
||||||
block.removeHeader(HttpNames.SCHEME);
|
frame.removeHeader(HttpNames.SCHEME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the URL scheme header.
|
* Returns the value of the URL scheme header.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static String getScheme(int spdyVersion, SpdyHeadersFrame frame) {
|
||||||
public static String getScheme(SpdyHeaderBlock block) {
|
|
||||||
return getScheme(2, block);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the value of the URL scheme header.
|
|
||||||
*/
|
|
||||||
public static String getScheme(int spdyVersion, SpdyHeaderBlock block) {
|
|
||||||
if (spdyVersion < 3) {
|
if (spdyVersion < 3) {
|
||||||
return block.getHeader(Spdy2HttpNames.SCHEME);
|
return frame.getHeader(Spdy2HttpNames.SCHEME);
|
||||||
} else {
|
} else {
|
||||||
return block.getHeader(HttpNames.SCHEME);
|
return frame.getHeader(HttpNames.SCHEME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the URL scheme header.
|
* Sets the URL scheme header.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static void setScheme(int spdyVersion, SpdyHeadersFrame frame, String scheme) {
|
||||||
public static void setScheme(SpdyHeaderBlock block, String scheme) {
|
|
||||||
setScheme(2, block, scheme);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the URL scheme header.
|
|
||||||
*/
|
|
||||||
public static void setScheme(int spdyVersion, SpdyHeaderBlock block, String scheme) {
|
|
||||||
if (spdyVersion < 3) {
|
if (spdyVersion < 3) {
|
||||||
block.setHeader(Spdy2HttpNames.SCHEME, scheme);
|
frame.setHeader(Spdy2HttpNames.SCHEME, scheme);
|
||||||
} else {
|
} else {
|
||||||
block.setHeader(HttpNames.SCHEME, scheme);
|
frame.setHeader(HttpNames.SCHEME, scheme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the HTTP response status header.
|
* Removes the HTTP response status header.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static void removeStatus(int spdyVersion, SpdyHeadersFrame frame) {
|
||||||
public static void removeStatus(SpdyHeaderBlock block) {
|
|
||||||
removeMethod(2, block);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the HTTP response status header.
|
|
||||||
*/
|
|
||||||
public static void removeStatus(int spdyVersion, SpdyHeaderBlock block) {
|
|
||||||
if (spdyVersion < 3) {
|
if (spdyVersion < 3) {
|
||||||
block.removeHeader(Spdy2HttpNames.STATUS);
|
frame.removeHeader(Spdy2HttpNames.STATUS);
|
||||||
} else {
|
} else {
|
||||||
block.removeHeader(HttpNames.STATUS);
|
frame.removeHeader(HttpNames.STATUS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link HttpResponseStatus} represented by the HTTP response status header.
|
* Returns the {@link HttpResponseStatus} represented by the HTTP response status header.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static HttpResponseStatus getStatus(int spdyVersion, SpdyHeadersFrame frame) {
|
||||||
public static HttpResponseStatus getStatus(SpdyHeaderBlock block) {
|
|
||||||
return getStatus(2, block);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the {@link HttpResponseStatus} represented by the HTTP response status header.
|
|
||||||
*/
|
|
||||||
public static HttpResponseStatus getStatus(int spdyVersion, SpdyHeaderBlock block) {
|
|
||||||
try {
|
try {
|
||||||
String status;
|
String status;
|
||||||
if (spdyVersion < 3) {
|
if (spdyVersion < 3) {
|
||||||
status = block.getHeader(Spdy2HttpNames.STATUS);
|
status = frame.getHeader(Spdy2HttpNames.STATUS);
|
||||||
} else {
|
} else {
|
||||||
status = block.getHeader(HttpNames.STATUS);
|
status = frame.getHeader(HttpNames.STATUS);
|
||||||
}
|
}
|
||||||
int space = status.indexOf(' ');
|
int space = status.indexOf(' ');
|
||||||
if (space == -1) {
|
if (space == -1) {
|
||||||
@ -344,115 +280,67 @@ public class SpdyHeaders {
|
|||||||
/**
|
/**
|
||||||
* Sets the HTTP response status header.
|
* Sets the HTTP response status header.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static void setStatus(int spdyVersion, SpdyHeadersFrame frame, HttpResponseStatus status) {
|
||||||
public static void setStatus(SpdyHeaderBlock block, HttpResponseStatus status) {
|
|
||||||
setStatus(2, block, status);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the HTTP response status header.
|
|
||||||
*/
|
|
||||||
public static void setStatus(int spdyVersion, SpdyHeaderBlock block, HttpResponseStatus status) {
|
|
||||||
if (spdyVersion < 3) {
|
if (spdyVersion < 3) {
|
||||||
block.setHeader(Spdy2HttpNames.STATUS, status.toString());
|
frame.setHeader(Spdy2HttpNames.STATUS, status.toString());
|
||||||
} else {
|
} else {
|
||||||
block.setHeader(HttpNames.STATUS, status.toString());
|
frame.setHeader(HttpNames.STATUS, status.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the URL path header.
|
* Removes the URL path header.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static void removeUrl(int spdyVersion, SpdyHeadersFrame frame) {
|
||||||
public static void removeUrl(SpdyHeaderBlock block) {
|
|
||||||
removeUrl(2, block);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the URL path header.
|
|
||||||
*/
|
|
||||||
public static void removeUrl(int spdyVersion, SpdyHeaderBlock block) {
|
|
||||||
if (spdyVersion < 3) {
|
if (spdyVersion < 3) {
|
||||||
block.removeHeader(Spdy2HttpNames.URL);
|
frame.removeHeader(Spdy2HttpNames.URL);
|
||||||
} else {
|
} else {
|
||||||
block.removeHeader(HttpNames.PATH);
|
frame.removeHeader(HttpNames.PATH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the URL path header.
|
* Returns the value of the URL path header.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static String getUrl(int spdyVersion, SpdyHeadersFrame frame) {
|
||||||
public static String getUrl(SpdyHeaderBlock block) {
|
|
||||||
return getUrl(2, block);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the value of the URL path header.
|
|
||||||
*/
|
|
||||||
public static String getUrl(int spdyVersion, SpdyHeaderBlock block) {
|
|
||||||
if (spdyVersion < 3) {
|
if (spdyVersion < 3) {
|
||||||
return block.getHeader(Spdy2HttpNames.URL);
|
return frame.getHeader(Spdy2HttpNames.URL);
|
||||||
} else {
|
} else {
|
||||||
return block.getHeader(HttpNames.PATH);
|
return frame.getHeader(HttpNames.PATH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the URL path header.
|
* Sets the URL path header.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static void setUrl(int spdyVersion, SpdyHeadersFrame frame, String path) {
|
||||||
public static void setUrl(SpdyHeaderBlock block, String path) {
|
|
||||||
setUrl(2, block, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the URL path header.
|
|
||||||
*/
|
|
||||||
public static void setUrl(int spdyVersion, SpdyHeaderBlock block, String path) {
|
|
||||||
if (spdyVersion < 3) {
|
if (spdyVersion < 3) {
|
||||||
block.setHeader(Spdy2HttpNames.URL, path);
|
frame.setHeader(Spdy2HttpNames.URL, path);
|
||||||
} else {
|
} else {
|
||||||
block.setHeader(HttpNames.PATH, path);
|
frame.setHeader(HttpNames.PATH, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the HTTP version header.
|
* Removes the HTTP version header.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static void removeVersion(int spdyVersion, SpdyHeadersFrame frame) {
|
||||||
public static void removeVersion(SpdyHeaderBlock block) {
|
|
||||||
removeVersion(2, block);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the HTTP version header.
|
|
||||||
*/
|
|
||||||
public static void removeVersion(int spdyVersion, SpdyHeaderBlock block) {
|
|
||||||
if (spdyVersion < 3) {
|
if (spdyVersion < 3) {
|
||||||
block.removeHeader(Spdy2HttpNames.VERSION);
|
frame.removeHeader(Spdy2HttpNames.VERSION);
|
||||||
} else {
|
} else {
|
||||||
block.removeHeader(HttpNames.VERSION);
|
frame.removeHeader(HttpNames.VERSION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link HttpVersion} represented by the HTTP version header.
|
* Returns the {@link HttpVersion} represented by the HTTP version header.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static HttpVersion getVersion(int spdyVersion, SpdyHeadersFrame frame) {
|
||||||
public static HttpVersion getVersion(SpdyHeaderBlock block) {
|
|
||||||
return getVersion(2, block);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the {@link HttpVersion} represented by the HTTP version header.
|
|
||||||
*/
|
|
||||||
public static HttpVersion getVersion(int spdyVersion, SpdyHeaderBlock block) {
|
|
||||||
try {
|
try {
|
||||||
if (spdyVersion < 3) {
|
if (spdyVersion < 3) {
|
||||||
return HttpVersion.valueOf(block.getHeader(Spdy2HttpNames.VERSION));
|
return HttpVersion.valueOf(frame.getHeader(Spdy2HttpNames.VERSION));
|
||||||
} else {
|
} else {
|
||||||
return HttpVersion.valueOf(block.getHeader(HttpNames.VERSION));
|
return HttpVersion.valueOf(frame.getHeader(HttpNames.VERSION));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
@ -462,19 +350,11 @@ public class SpdyHeaders {
|
|||||||
/**
|
/**
|
||||||
* Sets the HTTP version header.
|
* Sets the HTTP version header.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static void setVersion(int spdyVersion, SpdyHeadersFrame frame, HttpVersion httpVersion) {
|
||||||
public static void setVersion(SpdyHeaderBlock block, HttpVersion httpVersion) {
|
|
||||||
setVersion(2, block, httpVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the HTTP version header.
|
|
||||||
*/
|
|
||||||
public static void setVersion(int spdyVersion, SpdyHeaderBlock block, HttpVersion httpVersion) {
|
|
||||||
if (spdyVersion < 3) {
|
if (spdyVersion < 3) {
|
||||||
block.setHeader(Spdy2HttpNames.VERSION, httpVersion.getText());
|
frame.setHeader(Spdy2HttpNames.VERSION, httpVersion.getText());
|
||||||
} else {
|
} else {
|
||||||
block.setHeader(HttpNames.VERSION, httpVersion.getText());
|
frame.setHeader(HttpNames.VERSION, httpVersion.getText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -15,41 +15,86 @@
|
|||||||
*/
|
*/
|
||||||
package org.jboss.netty.handler.codec.spdy;
|
package org.jboss.netty.handler.codec.spdy;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A SPDY Protocol HEADERS Control Frame
|
* A SPDY Protocol HEADERS Frame
|
||||||
*/
|
*/
|
||||||
public interface SpdyHeadersFrame extends SpdyHeaderBlock {
|
public interface SpdyHeadersFrame extends SpdyStreamFrame {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #getStreamId()} instead.
|
* Returns {@code true} if this header block is invalid.
|
||||||
|
* A RST_STREAM frame with code PROTOCOL_ERROR should be sent.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
boolean isInvalid();
|
||||||
int getStreamID();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Stream-ID of this frame.
|
* Marks this header block as invalid.
|
||||||
*/
|
*/
|
||||||
int getStreamId();
|
void setInvalid();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #setStreamId(int)} instead.
|
* Returns the header value with the specified header name. If there is
|
||||||
|
* more than one header value for the specified header name, the first
|
||||||
|
* value is returned.
|
||||||
|
*
|
||||||
|
* @return the header value or {@code null} if there is no such header
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
String getHeader(String name);
|
||||||
void setStreamID(int streamId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the Stream-ID of this frame. The Stream-ID must be positive.
|
* Returns the header values with the specified header name.
|
||||||
|
*
|
||||||
|
* @return the {@link List} of header values. An empty list if there is no
|
||||||
|
* such header.
|
||||||
*/
|
*/
|
||||||
void setStreamId(int streamId);
|
List<String> getHeaders(String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code true} if this frame is the last frame to be transmitted
|
* Returns all header names and values that this block contains.
|
||||||
* on the stream.
|
*
|
||||||
|
* @return the {@link List} of the header name-value pairs. An empty list
|
||||||
|
* if there is no header in this message.
|
||||||
*/
|
*/
|
||||||
boolean isLast();
|
List<Map.Entry<String, String>> getHeaders();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets if this frame is the last frame to be transmitted on the stream.
|
* Returns {@code true} if and only if there is a header with the specified
|
||||||
|
* header name.
|
||||||
*/
|
*/
|
||||||
void setLast(boolean last);
|
boolean containsHeader(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link Set} of all header names that this block contains.
|
||||||
|
*/
|
||||||
|
Set<String> getHeaderNames();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a new header with the specified name and value.
|
||||||
|
*/
|
||||||
|
void addHeader(String name, Object value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a new header with the specified name and value. If there is an
|
||||||
|
* existing header with the same name, the existing header is removed.
|
||||||
|
*/
|
||||||
|
void setHeader(String name, Object value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a new header with the specified name and values. If there is an
|
||||||
|
* existing header with the same name, the existing header is removed.
|
||||||
|
*/
|
||||||
|
void setHeader(String name, Iterable<?> values);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the header with the specified name.
|
||||||
|
*/
|
||||||
|
void removeHeader(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all headers from this block.
|
||||||
|
*/
|
||||||
|
void clearHeaders();
|
||||||
}
|
}
|
||||||
|
@ -30,14 +30,6 @@ public class SpdyHttpCodec implements ChannelUpstreamHandler, ChannelDownstreamH
|
|||||||
private final SpdyHttpDecoder decoder;
|
private final SpdyHttpDecoder decoder;
|
||||||
private final SpdyHttpEncoder encoder;
|
private final SpdyHttpEncoder encoder;
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new instance with the specified decoder options.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public SpdyHttpCodec(int maxContentLength) {
|
|
||||||
this(2, maxContentLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance with the specified decoder options.
|
* Creates a new instance with the specified decoder options.
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -47,18 +47,6 @@ public class SpdyHttpDecoder extends OneToOneDecoder {
|
|||||||
private final int maxContentLength;
|
private final int maxContentLength;
|
||||||
private final Map<Integer, HttpMessage> messageMap;
|
private final Map<Integer, HttpMessage> messageMap;
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new instance for the SPDY/2 protocol
|
|
||||||
*
|
|
||||||
* @param maxContentLength the maximum length of the message content.
|
|
||||||
* If the length of the message content exceeds this value,
|
|
||||||
* a {@link TooLongFrameException} will be raised.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public SpdyHttpDecoder(int maxContentLength) {
|
|
||||||
this(2, maxContentLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
*
|
*
|
||||||
@ -274,7 +262,7 @@ public class SpdyHttpDecoder extends OneToOneDecoder {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HttpRequest createHttpRequest(int spdyVersion, SpdyHeaderBlock requestFrame)
|
private static HttpRequest createHttpRequest(int spdyVersion, SpdyHeadersFrame requestFrame)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
// Create the first line of the request from the name/value pairs
|
// Create the first line of the request from the name/value pairs
|
||||||
HttpMethod method = SpdyHeaders.getMethod(spdyVersion, requestFrame);
|
HttpMethod method = SpdyHeaders.getMethod(spdyVersion, requestFrame);
|
||||||
@ -309,7 +297,7 @@ public class SpdyHttpDecoder extends OneToOneDecoder {
|
|||||||
return httpRequest;
|
return httpRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HttpResponse createHttpResponse(int spdyVersion, SpdyHeaderBlock responseFrame)
|
private static HttpResponse createHttpResponse(int spdyVersion, SpdyHeadersFrame responseFrame)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
// Create the first line of the response from the name/value pairs
|
// Create the first line of the response from the name/value pairs
|
||||||
HttpResponseStatus status = SpdyHeaders.getStatus(spdyVersion, responseFrame);
|
HttpResponseStatus status = SpdyHeaders.getStatus(spdyVersion, responseFrame);
|
||||||
|
@ -128,14 +128,6 @@ public class SpdyHttpEncoder implements ChannelDownstreamHandler {
|
|||||||
private final int spdyVersion;
|
private final int spdyVersion;
|
||||||
private volatile int currentStreamID;
|
private volatile int currentStreamID;
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new instance for the SPDY/2 protocol
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public SpdyHttpEncoder() {
|
|
||||||
this(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
*
|
*
|
||||||
@ -333,7 +325,7 @@ public class SpdyHttpEncoder implements ChannelDownstreamHandler {
|
|||||||
int streamID = SpdyHttpHeaders.getStreamId(httpResponse);
|
int streamID = SpdyHttpHeaders.getStreamId(httpResponse);
|
||||||
SpdyHttpHeaders.removeStreamId(httpResponse);
|
SpdyHttpHeaders.removeStreamId(httpResponse);
|
||||||
|
|
||||||
// The Connection, Keep-Alive, Proxy-Connection, and Transfer-ENcoding
|
// The Connection, Keep-Alive, Proxy-Connection, and Transfer-Encoding
|
||||||
// headers are not valid and MUST not be sent.
|
// headers are not valid and MUST not be sent.
|
||||||
httpResponse.removeHeader(HttpHeaders.Names.CONNECTION);
|
httpResponse.removeHeader(HttpHeaders.Names.CONNECTION);
|
||||||
httpResponse.removeHeader("Keep-Alive");
|
httpResponse.removeHeader("Keep-Alive");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -58,14 +58,6 @@ public final class SpdyHttpHeaders {
|
|||||||
private SpdyHttpHeaders() {
|
private SpdyHttpHeaders() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #removeStreamId(HttpMessage)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static void removeStreamID(HttpMessage message) {
|
|
||||||
removeStreamId(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the {@code "X-SPDY-Stream-ID"} header.
|
* Removes the {@code "X-SPDY-Stream-ID"} header.
|
||||||
*/
|
*/
|
||||||
@ -73,14 +65,6 @@ public final class SpdyHttpHeaders {
|
|||||||
message.removeHeader(Names.STREAM_ID);
|
message.removeHeader(Names.STREAM_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #getStreamId(HttpMessage)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static int getStreamID(HttpMessage message) {
|
|
||||||
return getStreamId(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the {@code "X-SPDY-Stream-ID"} header.
|
* Returns the value of the {@code "X-SPDY-Stream-ID"} header.
|
||||||
*/
|
*/
|
||||||
@ -88,14 +72,6 @@ public final class SpdyHttpHeaders {
|
|||||||
return HttpHeaders.getIntHeader(message, Names.STREAM_ID);
|
return HttpHeaders.getIntHeader(message, Names.STREAM_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #setStreamId(HttpMessage, int)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static void setStreamID(HttpMessage message, int streamId) {
|
|
||||||
setStreamId(message, streamId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@code "X-SPDY-Stream-ID"} header.
|
* Sets the {@code "X-SPDY-Stream-ID"} header.
|
||||||
*/
|
*/
|
||||||
@ -103,14 +79,6 @@ public final class SpdyHttpHeaders {
|
|||||||
HttpHeaders.setIntHeader(message, Names.STREAM_ID, streamId);
|
HttpHeaders.setIntHeader(message, Names.STREAM_ID, streamId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #removeAssociatedToStreamId(HttpMessage)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static void removeAssociatedToStreamID(HttpMessage message) {
|
|
||||||
removeAssociatedToStreamId(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the {@code "X-SPDY-Associated-To-Stream-ID"} header.
|
* Removes the {@code "X-SPDY-Associated-To-Stream-ID"} header.
|
||||||
*/
|
*/
|
||||||
@ -118,14 +86,6 @@ public final class SpdyHttpHeaders {
|
|||||||
message.removeHeader(Names.ASSOCIATED_TO_STREAM_ID);
|
message.removeHeader(Names.ASSOCIATED_TO_STREAM_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #getAssociatedToStreamId(HttpMessage)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static int getAssociatedToStreamID(HttpMessage message) {
|
|
||||||
return getAssociatedToStreamId(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the {@code "X-SPDY-Associated-To-Stream-ID"} header.
|
* Returns the value of the {@code "X-SPDY-Associated-To-Stream-ID"} header.
|
||||||
*
|
*
|
||||||
@ -136,14 +96,6 @@ public final class SpdyHttpHeaders {
|
|||||||
return HttpHeaders.getIntHeader(message, Names.ASSOCIATED_TO_STREAM_ID, 0);
|
return HttpHeaders.getIntHeader(message, Names.ASSOCIATED_TO_STREAM_ID, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #setAssociatedToStreamId(HttpMessage, int)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static void setAssociatedToStreamID(HttpMessage message, int associatedToStreamId) {
|
|
||||||
setAssociatedToStreamId(message, associatedToStreamId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@code "X-SPDY-Associated-To-Stream-ID"} header.
|
* Sets the {@code "X-SPDY-Associated-To-Stream-ID"} header.
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -16,27 +16,15 @@
|
|||||||
package org.jboss.netty.handler.codec.spdy;
|
package org.jboss.netty.handler.codec.spdy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A SPDY Protocol PING Control Frame
|
* A SPDY Protocol PING Frame
|
||||||
*/
|
*/
|
||||||
public interface SpdyPingFrame {
|
public interface SpdyPingFrame extends SpdyFrame {
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #getId()} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
int getID();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ID of this frame.
|
* Returns the ID of this frame.
|
||||||
*/
|
*/
|
||||||
int getId();
|
int getId();
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #setId(int)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
void setID(int id);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the ID of this frame.
|
* Sets the ID of this frame.
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -16,31 +16,9 @@
|
|||||||
package org.jboss.netty.handler.codec.spdy;
|
package org.jboss.netty.handler.codec.spdy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A SPDY Protocol RST_STREAM Control Frame
|
* A SPDY Protocol RST_STREAM Frame
|
||||||
*/
|
*/
|
||||||
public interface SpdyRstStreamFrame {
|
public interface SpdyRstStreamFrame extends SpdyStreamFrame {
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #getStreamId()} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
int getStreamID();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the Stream-ID of this frame.
|
|
||||||
*/
|
|
||||||
int getStreamId();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #setStreamId(int)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
void setStreamID(int streamId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the Stream-ID of this frame. The Stream-ID must be positive.
|
|
||||||
*/
|
|
||||||
void setStreamId(int streamId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the status of this frame.
|
* Returns the status of this frame.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -42,7 +42,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
private static final SpdyProtocolException PROTOCOL_EXCEPTION = new SpdyProtocolException();
|
private static final SpdyProtocolException PROTOCOL_EXCEPTION = new SpdyProtocolException();
|
||||||
|
|
||||||
private final SpdySession spdySession = new SpdySession();
|
private final SpdySession spdySession = new SpdySession();
|
||||||
private volatile int lastGoodStreamID;
|
private volatile int lastGoodStreamId;
|
||||||
|
|
||||||
private volatile int remoteConcurrentStreams;
|
private volatile int remoteConcurrentStreams;
|
||||||
private volatile int localConcurrentStreams;
|
private volatile int localConcurrentStreams;
|
||||||
@ -64,19 +64,6 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
private final boolean server;
|
private final boolean server;
|
||||||
private final boolean flowControl;
|
private final boolean flowControl;
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new SPDY/2 session handler.
|
|
||||||
*
|
|
||||||
* @param server {@code true} if and only if this session handler should
|
|
||||||
* handle the server endpoint of the connection.
|
|
||||||
* {@code false} if and only if this session handler should
|
|
||||||
* handle the client endpoint of the connection.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public SpdySessionHandler(boolean server) {
|
|
||||||
this(2, server);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new session handler.
|
* Creates a new session handler.
|
||||||
*
|
*
|
||||||
@ -126,27 +113,27 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
|
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
|
||||||
int streamID = spdyDataFrame.getStreamId();
|
int streamId = spdyDataFrame.getStreamId();
|
||||||
|
|
||||||
// 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
|
||||||
if (!spdySession.isActiveStream(streamID)) {
|
if (!spdySession.isActiveStream(streamId)) {
|
||||||
if (streamID <= lastGoodStreamID) {
|
if (streamId <= lastGoodStreamId) {
|
||||||
issueStreamError(ctx, e.getRemoteAddress(), streamID, SpdyStreamStatus.PROTOCOL_ERROR);
|
issueStreamError(ctx, e.getRemoteAddress(), streamId, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||||
} else if (!sentGoAwayFrame) {
|
} else if (!sentGoAwayFrame) {
|
||||||
issueStreamError(ctx, e.getRemoteAddress(), streamID, SpdyStreamStatus.INVALID_STREAM);
|
issueStreamError(ctx, e.getRemoteAddress(), streamId, SpdyStreamStatus.INVALID_STREAM);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we received a data frame for a stream which is half-closed
|
// Check if we received a data frame for a stream which is half-closed
|
||||||
if (spdySession.isRemoteSideClosed(streamID)) {
|
if (spdySession.isRemoteSideClosed(streamId)) {
|
||||||
issueStreamError(ctx, e.getRemoteAddress(), streamID, SpdyStreamStatus.STREAM_ALREADY_CLOSED);
|
issueStreamError(ctx, e.getRemoteAddress(), streamId, SpdyStreamStatus.STREAM_ALREADY_CLOSED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we received a data frame before receiving a SYN_REPLY
|
// Check if we received a data frame before receiving a SYN_REPLY
|
||||||
if (!isRemoteInitiatedID(streamID) && !spdySession.hasReceivedReply(streamID)) {
|
if (!isRemoteInitiatedID(streamId) && !spdySession.hasReceivedReply(streamId)) {
|
||||||
issueStreamError(ctx, e.getRemoteAddress(), streamID, SpdyStreamStatus.PROTOCOL_ERROR);
|
issueStreamError(ctx, e.getRemoteAddress(), streamId, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,15 +146,15 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
if (flowControl) {
|
if (flowControl) {
|
||||||
// Update receive window size
|
// Update receive window size
|
||||||
int deltaWindowSize = -1 * spdyDataFrame.getData().readableBytes();
|
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
|
||||||
// size of the transfer window after the peer has written data frames.
|
// size of the transfer window after the peer has written data frames.
|
||||||
// The value is bounded by the length that SETTINGS frame decrease the window.
|
// The value is bounded by the length that SETTINGS frame decrease the window.
|
||||||
// This difference is stored for the session when writing the SETTINGS frame
|
// This difference is stored for the session when writing the SETTINGS frame
|
||||||
// and is cleared once we send a WINDOW_UPDATE frame.
|
// and is cleared once we send a WINDOW_UPDATE frame.
|
||||||
if (newWindowSize < spdySession.getReceiveWindowSizeLowerBound(streamID)) {
|
if (newWindowSize < spdySession.getReceiveWindowSizeLowerBound(streamId)) {
|
||||||
issueStreamError(ctx, e.getRemoteAddress(), streamID, SpdyStreamStatus.FLOW_CONTROL_ERROR);
|
issueStreamError(ctx, e.getRemoteAddress(), streamId, SpdyStreamStatus.FLOW_CONTROL_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +162,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
// Send data frames upstream in initialReceiveWindowSize chunks
|
// Send data frames upstream in initialReceiveWindowSize chunks
|
||||||
if (newWindowSize < 0) {
|
if (newWindowSize < 0) {
|
||||||
while (spdyDataFrame.getData().readableBytes() > initialReceiveWindowSize) {
|
while (spdyDataFrame.getData().readableBytes() > initialReceiveWindowSize) {
|
||||||
SpdyDataFrame partialDataFrame = new DefaultSpdyDataFrame(streamID);
|
SpdyDataFrame partialDataFrame = new DefaultSpdyDataFrame(streamId);
|
||||||
partialDataFrame.setData(spdyDataFrame.getData().readSlice(initialReceiveWindowSize));
|
partialDataFrame.setData(spdyDataFrame.getData().readSlice(initialReceiveWindowSize));
|
||||||
Channels.fireMessageReceived(ctx, partialDataFrame, e.getRemoteAddress());
|
Channels.fireMessageReceived(ctx, partialDataFrame, e.getRemoteAddress());
|
||||||
}
|
}
|
||||||
@ -184,9 +171,9 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
// Send a WINDOW_UPDATE frame if less than half the window size remains
|
// Send a WINDOW_UPDATE frame if less than half the window size remains
|
||||||
if (newWindowSize <= initialReceiveWindowSize / 2 && !spdyDataFrame.isLast()) {
|
if (newWindowSize <= initialReceiveWindowSize / 2 && !spdyDataFrame.isLast()) {
|
||||||
deltaWindowSize = initialReceiveWindowSize - newWindowSize;
|
deltaWindowSize = initialReceiveWindowSize - newWindowSize;
|
||||||
spdySession.updateReceiveWindowSize(streamID, deltaWindowSize);
|
spdySession.updateReceiveWindowSize(streamId, deltaWindowSize);
|
||||||
SpdyWindowUpdateFrame spdyWindowUpdateFrame =
|
SpdyWindowUpdateFrame spdyWindowUpdateFrame =
|
||||||
new DefaultSpdyWindowUpdateFrame(streamID, deltaWindowSize);
|
new DefaultSpdyWindowUpdateFrame(streamId, deltaWindowSize);
|
||||||
Channels.write(
|
Channels.write(
|
||||||
ctx, Channels.future(e.getChannel()), spdyWindowUpdateFrame, e.getRemoteAddress());
|
ctx, Channels.future(e.getChannel()), spdyWindowUpdateFrame, e.getRemoteAddress());
|
||||||
}
|
}
|
||||||
@ -194,7 +181,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
|
|
||||||
// Close the remote side of the stream if this is the last frame
|
// Close the remote side of the stream if this is the last frame
|
||||||
if (spdyDataFrame.isLast()) {
|
if (spdyDataFrame.isLast()) {
|
||||||
halfCloseStream(streamID, true);
|
halfCloseStream(streamId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (msg instanceof SpdySynStreamFrame) {
|
} else if (msg instanceof SpdySynStreamFrame) {
|
||||||
@ -214,18 +201,18 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
SpdySynStreamFrame spdySynStreamFrame = (SpdySynStreamFrame) msg;
|
SpdySynStreamFrame spdySynStreamFrame = (SpdySynStreamFrame) msg;
|
||||||
int streamID = spdySynStreamFrame.getStreamId();
|
int streamId = spdySynStreamFrame.getStreamId();
|
||||||
|
|
||||||
// Check if we received a valid SYN_STREAM frame
|
// Check if we received a valid SYN_STREAM frame
|
||||||
if (spdySynStreamFrame.isInvalid() ||
|
if (spdySynStreamFrame.isInvalid() ||
|
||||||
!isRemoteInitiatedID(streamID) ||
|
!isRemoteInitiatedID(streamId) ||
|
||||||
spdySession.isActiveStream(streamID)) {
|
spdySession.isActiveStream(streamId)) {
|
||||||
issueStreamError(ctx, e.getRemoteAddress(), streamID, SpdyStreamStatus.PROTOCOL_ERROR);
|
issueStreamError(ctx, e.getRemoteAddress(), streamId, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stream-IDs must be monotonically increasing
|
// Stream-IDs must be monotonically increasing
|
||||||
if (streamID <= lastGoodStreamID) {
|
if (streamId <= lastGoodStreamId) {
|
||||||
issueSessionError(ctx, e.getChannel(), e.getRemoteAddress(), SpdySessionStatus.PROTOCOL_ERROR);
|
issueSessionError(ctx, e.getChannel(), e.getRemoteAddress(), SpdySessionStatus.PROTOCOL_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -234,8 +221,8 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
byte priority = spdySynStreamFrame.getPriority();
|
byte priority = spdySynStreamFrame.getPriority();
|
||||||
boolean remoteSideClosed = spdySynStreamFrame.isLast();
|
boolean remoteSideClosed = spdySynStreamFrame.isLast();
|
||||||
boolean localSideClosed = spdySynStreamFrame.isUnidirectional();
|
boolean localSideClosed = spdySynStreamFrame.isUnidirectional();
|
||||||
if (!acceptStream(streamID, priority, remoteSideClosed, localSideClosed)) {
|
if (!acceptStream(streamId, priority, remoteSideClosed, localSideClosed)) {
|
||||||
issueStreamError(ctx, e.getRemoteAddress(), streamID, SpdyStreamStatus.REFUSED_STREAM);
|
issueStreamError(ctx, e.getRemoteAddress(), streamId, SpdyStreamStatus.REFUSED_STREAM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,27 +236,27 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
SpdySynReplyFrame spdySynReplyFrame = (SpdySynReplyFrame) msg;
|
SpdySynReplyFrame spdySynReplyFrame = (SpdySynReplyFrame) msg;
|
||||||
int streamID = spdySynReplyFrame.getStreamId();
|
int streamId = spdySynReplyFrame.getStreamId();
|
||||||
|
|
||||||
// Check if we received a valid SYN_REPLY frame
|
// Check if we received a valid SYN_REPLY frame
|
||||||
if (spdySynReplyFrame.isInvalid() ||
|
if (spdySynReplyFrame.isInvalid() ||
|
||||||
isRemoteInitiatedID(streamID) ||
|
isRemoteInitiatedID(streamId) ||
|
||||||
spdySession.isRemoteSideClosed(streamID)) {
|
spdySession.isRemoteSideClosed(streamId)) {
|
||||||
issueStreamError(ctx, e.getRemoteAddress(), streamID, SpdyStreamStatus.INVALID_STREAM);
|
issueStreamError(ctx, e.getRemoteAddress(), streamId, SpdyStreamStatus.INVALID_STREAM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we have received multiple frames for the same Stream-ID
|
// Check if we have received multiple frames for the same Stream-ID
|
||||||
if (spdySession.hasReceivedReply(streamID)) {
|
if (spdySession.hasReceivedReply(streamId)) {
|
||||||
issueStreamError(ctx, e.getRemoteAddress(), streamID, SpdyStreamStatus.STREAM_IN_USE);
|
issueStreamError(ctx, e.getRemoteAddress(), streamId, SpdyStreamStatus.STREAM_IN_USE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
spdySession.receivedReply(streamID);
|
spdySession.receivedReply(streamId);
|
||||||
|
|
||||||
// Close the remote side of the stream if this is the last frame
|
// Close the remote side of the stream if this is the last frame
|
||||||
if (spdySynReplyFrame.isLast()) {
|
if (spdySynReplyFrame.isLast()) {
|
||||||
halfCloseStream(streamID, true);
|
halfCloseStream(streamId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (msg instanceof SpdyRstStreamFrame) {
|
} else if (msg instanceof SpdyRstStreamFrame) {
|
||||||
@ -343,22 +330,22 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
} else if (msg instanceof SpdyHeadersFrame) {
|
} else if (msg instanceof SpdyHeadersFrame) {
|
||||||
|
|
||||||
SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg;
|
SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg;
|
||||||
int streamID = spdyHeadersFrame.getStreamId();
|
int streamId = spdyHeadersFrame.getStreamId();
|
||||||
|
|
||||||
// Check if we received a valid HEADERS frame
|
// Check if we received a valid HEADERS frame
|
||||||
if (spdyHeadersFrame.isInvalid()) {
|
if (spdyHeadersFrame.isInvalid()) {
|
||||||
issueStreamError(ctx, e.getRemoteAddress(), streamID, SpdyStreamStatus.PROTOCOL_ERROR);
|
issueStreamError(ctx, e.getRemoteAddress(), streamId, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spdySession.isRemoteSideClosed(streamID)) {
|
if (spdySession.isRemoteSideClosed(streamId)) {
|
||||||
issueStreamError(ctx, e.getRemoteAddress(), streamID, SpdyStreamStatus.INVALID_STREAM);
|
issueStreamError(ctx, e.getRemoteAddress(), streamId, SpdyStreamStatus.INVALID_STREAM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the remote side of the stream if this is the last frame
|
// Close the remote side of the stream if this is the last frame
|
||||||
if (spdyHeadersFrame.isLast()) {
|
if (spdyHeadersFrame.isLast()) {
|
||||||
halfCloseStream(streamID, true);
|
halfCloseStream(streamId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (msg instanceof SpdyWindowUpdateFrame) {
|
} else if (msg instanceof SpdyWindowUpdateFrame) {
|
||||||
@ -375,21 +362,21 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
|
|
||||||
if (flowControl) {
|
if (flowControl) {
|
||||||
SpdyWindowUpdateFrame spdyWindowUpdateFrame = (SpdyWindowUpdateFrame) msg;
|
SpdyWindowUpdateFrame spdyWindowUpdateFrame = (SpdyWindowUpdateFrame) msg;
|
||||||
int streamID = spdyWindowUpdateFrame.getStreamId();
|
int streamId = spdyWindowUpdateFrame.getStreamId();
|
||||||
int deltaWindowSize = spdyWindowUpdateFrame.getDeltaWindowSize();
|
int deltaWindowSize = spdyWindowUpdateFrame.getDeltaWindowSize();
|
||||||
|
|
||||||
// Ignore frames for half-closed streams
|
// Ignore frames for half-closed streams
|
||||||
if (spdySession.isLocalSideClosed(streamID)) {
|
if (spdySession.isLocalSideClosed(streamId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for numerical overflow
|
// Check for numerical overflow
|
||||||
if (spdySession.getSendWindowSize(streamID) > Integer.MAX_VALUE - deltaWindowSize) {
|
if (spdySession.getSendWindowSize(streamId) > Integer.MAX_VALUE - deltaWindowSize) {
|
||||||
issueStreamError(ctx, e.getRemoteAddress(), streamID, SpdyStreamStatus.FLOW_CONTROL_ERROR);
|
issueStreamError(ctx, e.getRemoteAddress(), streamId, SpdyStreamStatus.FLOW_CONTROL_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSendWindowSize(ctx, streamID, deltaWindowSize);
|
updateSendWindowSize(ctx, streamId, deltaWindowSize);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -441,10 +428,10 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
if (msg instanceof SpdyDataFrame) {
|
if (msg instanceof SpdyDataFrame) {
|
||||||
|
|
||||||
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
|
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
|
||||||
final int streamID = spdyDataFrame.getStreamId();
|
final int streamId = spdyDataFrame.getStreamId();
|
||||||
|
|
||||||
// Frames must not be sent on half-closed streams
|
// Frames must not be sent on half-closed streams
|
||||||
if (spdySession.isLocalSideClosed(streamID)) {
|
if (spdySession.isLocalSideClosed(streamId)) {
|
||||||
e.getFuture().setFailure(PROTOCOL_EXCEPTION);
|
e.getFuture().setFailure(PROTOCOL_EXCEPTION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -465,22 +452,22 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
if (flowControl) {
|
if (flowControl) {
|
||||||
synchronized (flowControlLock) {
|
synchronized (flowControlLock) {
|
||||||
int dataLength = spdyDataFrame.getData().readableBytes();
|
int dataLength = spdyDataFrame.getData().readableBytes();
|
||||||
int sendWindowSize = spdySession.getSendWindowSize(streamID);
|
int sendWindowSize = spdySession.getSendWindowSize(streamId);
|
||||||
|
|
||||||
if (sendWindowSize <= 0) {
|
if (sendWindowSize <= 0) {
|
||||||
// Stream is stalled -- enqueue Data frame and return
|
// Stream is stalled -- enqueue Data frame and return
|
||||||
spdySession.putPendingWrite(streamID, e);
|
spdySession.putPendingWrite(streamId, e);
|
||||||
return;
|
return;
|
||||||
} 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);
|
||||||
|
|
||||||
// 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);
|
||||||
partialDataFrame.setData(spdyDataFrame.getData().readSlice(sendWindowSize));
|
partialDataFrame.setData(spdyDataFrame.getData().readSlice(sendWindowSize));
|
||||||
|
|
||||||
// Enqueue the remaining data (will be the first frame queued)
|
// Enqueue the remaining data (will be the first frame queued)
|
||||||
spdySession.putPendingWrite(streamID, e);
|
spdySession.putPendingWrite(streamId, e);
|
||||||
|
|
||||||
ChannelFuture writeFuture = Channels.future(e.getChannel());
|
ChannelFuture writeFuture = Channels.future(e.getChannel());
|
||||||
|
|
||||||
@ -492,7 +479,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
public void operationComplete(ChannelFuture future) throws Exception {
|
public void operationComplete(ChannelFuture future) throws Exception {
|
||||||
if (!future.isSuccess()) {
|
if (!future.isSuccess()) {
|
||||||
issueStreamError(
|
issueStreamError(
|
||||||
context, remoteAddress, streamID, SpdyStreamStatus.INTERNAL_ERROR);
|
context, remoteAddress, streamId, SpdyStreamStatus.INTERNAL_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -501,7 +488,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
return;
|
return;
|
||||||
} 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);
|
||||||
|
|
||||||
// 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 stream on write failures that leaves the transfer window in a corrupt state.
|
// Close the stream on write failures that leaves the transfer window in a corrupt state.
|
||||||
@ -511,7 +498,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
public void operationComplete(ChannelFuture future) throws Exception {
|
public void operationComplete(ChannelFuture future) throws Exception {
|
||||||
if (!future.isSuccess()) {
|
if (!future.isSuccess()) {
|
||||||
issueStreamError(
|
issueStreamError(
|
||||||
context, remoteAddress, streamID, SpdyStreamStatus.INTERNAL_ERROR);
|
context, remoteAddress, streamId, SpdyStreamStatus.INTERNAL_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -521,15 +508,15 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
|
|
||||||
// Close the local side of the stream if this is the last frame
|
// Close the local side of the stream if this is the last frame
|
||||||
if (spdyDataFrame.isLast()) {
|
if (spdyDataFrame.isLast()) {
|
||||||
halfCloseStream(streamID, false);
|
halfCloseStream(streamId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (msg instanceof SpdySynStreamFrame) {
|
} else if (msg instanceof SpdySynStreamFrame) {
|
||||||
|
|
||||||
SpdySynStreamFrame spdySynStreamFrame = (SpdySynStreamFrame) msg;
|
SpdySynStreamFrame spdySynStreamFrame = (SpdySynStreamFrame) msg;
|
||||||
int streamID = spdySynStreamFrame.getStreamId();
|
int streamId = spdySynStreamFrame.getStreamId();
|
||||||
|
|
||||||
if (isRemoteInitiatedID(streamID)) {
|
if (isRemoteInitiatedID(streamId)) {
|
||||||
e.getFuture().setFailure(PROTOCOL_EXCEPTION);
|
e.getFuture().setFailure(PROTOCOL_EXCEPTION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -537,7 +524,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
byte priority = spdySynStreamFrame.getPriority();
|
byte priority = spdySynStreamFrame.getPriority();
|
||||||
boolean remoteSideClosed = spdySynStreamFrame.isUnidirectional();
|
boolean remoteSideClosed = spdySynStreamFrame.isUnidirectional();
|
||||||
boolean localSideClosed = spdySynStreamFrame.isLast();
|
boolean localSideClosed = spdySynStreamFrame.isLast();
|
||||||
if (!acceptStream(streamID, priority, remoteSideClosed, localSideClosed)) {
|
if (!acceptStream(streamId, priority, remoteSideClosed, localSideClosed)) {
|
||||||
e.getFuture().setFailure(PROTOCOL_EXCEPTION);
|
e.getFuture().setFailure(PROTOCOL_EXCEPTION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -545,17 +532,17 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
} else if (msg instanceof SpdySynReplyFrame) {
|
} else if (msg instanceof SpdySynReplyFrame) {
|
||||||
|
|
||||||
SpdySynReplyFrame spdySynReplyFrame = (SpdySynReplyFrame) msg;
|
SpdySynReplyFrame spdySynReplyFrame = (SpdySynReplyFrame) msg;
|
||||||
int streamID = spdySynReplyFrame.getStreamId();
|
int streamId = spdySynReplyFrame.getStreamId();
|
||||||
|
|
||||||
// Frames must not be sent on half-closed streams
|
// Frames must not be sent on half-closed streams
|
||||||
if (!isRemoteInitiatedID(streamID) || spdySession.isLocalSideClosed(streamID)) {
|
if (!isRemoteInitiatedID(streamId) || spdySession.isLocalSideClosed(streamId)) {
|
||||||
e.getFuture().setFailure(PROTOCOL_EXCEPTION);
|
e.getFuture().setFailure(PROTOCOL_EXCEPTION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the local side of the stream if this is the last frame
|
// Close the local side of the stream if this is the last frame
|
||||||
if (spdySynReplyFrame.isLast()) {
|
if (spdySynReplyFrame.isLast()) {
|
||||||
halfCloseStream(streamID, false);
|
halfCloseStream(streamId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (msg instanceof SpdyRstStreamFrame) {
|
} else if (msg instanceof SpdyRstStreamFrame) {
|
||||||
@ -609,17 +596,17 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
} else if (msg instanceof SpdyHeadersFrame) {
|
} else if (msg instanceof SpdyHeadersFrame) {
|
||||||
|
|
||||||
SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg;
|
SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg;
|
||||||
int streamID = spdyHeadersFrame.getStreamId();
|
int streamId = spdyHeadersFrame.getStreamId();
|
||||||
|
|
||||||
// Frames must not be sent on half-closed streams
|
// Frames must not be sent on half-closed streams
|
||||||
if (spdySession.isLocalSideClosed(streamID)) {
|
if (spdySession.isLocalSideClosed(streamId)) {
|
||||||
e.getFuture().setFailure(PROTOCOL_EXCEPTION);
|
e.getFuture().setFailure(PROTOCOL_EXCEPTION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the local side of the stream if this is the last frame
|
// Close the local side of the stream if this is the last frame
|
||||||
if (spdyHeadersFrame.isLast()) {
|
if (spdyHeadersFrame.isLast()) {
|
||||||
halfCloseStream(streamID, false);
|
halfCloseStream(streamId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (msg instanceof SpdyWindowUpdateFrame) {
|
} else if (msg instanceof SpdyWindowUpdateFrame) {
|
||||||
@ -660,12 +647,12 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
* Note: this is only called by the worker thread
|
* Note: this is only called by the worker thread
|
||||||
*/
|
*/
|
||||||
private void issueStreamError(
|
private void issueStreamError(
|
||||||
ChannelHandlerContext ctx, SocketAddress remoteAddress, int streamID, SpdyStreamStatus status) {
|
ChannelHandlerContext ctx, SocketAddress remoteAddress, int streamId, SpdyStreamStatus status) {
|
||||||
|
|
||||||
boolean fireMessageReceived = !spdySession.isRemoteSideClosed(streamID);
|
boolean fireMessageReceived = !spdySession.isRemoteSideClosed(streamId);
|
||||||
removeStream(streamID);
|
removeStream(streamId);
|
||||||
|
|
||||||
SpdyRstStreamFrame spdyRstStreamFrame = new DefaultSpdyRstStreamFrame(streamID, status);
|
SpdyRstStreamFrame spdyRstStreamFrame = new DefaultSpdyRstStreamFrame(streamId, status);
|
||||||
Channels.write(ctx, Channels.future(ctx.getChannel()), spdyRstStreamFrame, remoteAddress);
|
Channels.write(ctx, Channels.future(ctx.getChannel()), spdyRstStreamFrame, remoteAddress);
|
||||||
if (fireMessageReceived) {
|
if (fireMessageReceived) {
|
||||||
Channels.fireMessageReceived(ctx, spdyRstStreamFrame, remoteAddress);
|
Channels.fireMessageReceived(ctx, spdyRstStreamFrame, remoteAddress);
|
||||||
@ -710,8 +697,8 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
private synchronized void updateInitialSendWindowSize(int newInitialWindowSize) {
|
private synchronized void updateInitialSendWindowSize(int newInitialWindowSize) {
|
||||||
int deltaWindowSize = newInitialWindowSize - initialSendWindowSize;
|
int deltaWindowSize = newInitialWindowSize - initialSendWindowSize;
|
||||||
initialSendWindowSize = newInitialWindowSize;
|
initialSendWindowSize = newInitialWindowSize;
|
||||||
for (Integer StreamID: spdySession.getActiveStreams()) {
|
for (Integer StreamId: spdySession.getActiveStreams()) {
|
||||||
spdySession.updateSendWindowSize(StreamID.intValue(), deltaWindowSize);
|
spdySession.updateSendWindowSize(StreamId.intValue(), deltaWindowSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -722,9 +709,9 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
spdySession.updateAllReceiveWindowSizes(deltaWindowSize);
|
spdySession.updateAllReceiveWindowSizes(deltaWindowSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// need to synchronize accesses to sentGoAwayFrame, lastGoodStreamID, and initial window sizes
|
// need to synchronize accesses to sentGoAwayFrame, lastGoodStreamId, and initial window sizes
|
||||||
private synchronized boolean acceptStream(
|
private synchronized boolean acceptStream(
|
||||||
int streamID, byte priority, boolean remoteSideClosed, boolean localSideClosed) {
|
int streamId, byte priority, boolean remoteSideClosed, boolean localSideClosed) {
|
||||||
// Cannot initiate any new streams after receiving or sending GOAWAY
|
// Cannot initiate any new streams after receiving or sending GOAWAY
|
||||||
if (receivedGoAwayFrame || sentGoAwayFrame) {
|
if (receivedGoAwayFrame || sentGoAwayFrame) {
|
||||||
return false;
|
return false;
|
||||||
@ -736,39 +723,39 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
spdySession.acceptStream(
|
spdySession.acceptStream(
|
||||||
streamID, priority, remoteSideClosed, localSideClosed,
|
streamId, priority, remoteSideClosed, localSideClosed,
|
||||||
initialSendWindowSize, initialReceiveWindowSize);
|
initialSendWindowSize, initialReceiveWindowSize);
|
||||||
if (isRemoteInitiatedID(streamID)) {
|
if (isRemoteInitiatedID(streamId)) {
|
||||||
lastGoodStreamID = streamID;
|
lastGoodStreamId = streamId;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void halfCloseStream(int streamID, boolean remote) {
|
private void halfCloseStream(int streamId, boolean remote) {
|
||||||
if (remote) {
|
if (remote) {
|
||||||
spdySession.closeRemoteSide(streamID);
|
spdySession.closeRemoteSide(streamId);
|
||||||
} else {
|
} else {
|
||||||
spdySession.closeLocalSide(streamID);
|
spdySession.closeLocalSide(streamId);
|
||||||
}
|
}
|
||||||
if (closeSessionFuture != null && spdySession.noActiveStreams()) {
|
if (closeSessionFuture != null && spdySession.noActiveStreams()) {
|
||||||
closeSessionFuture.setSuccess();
|
closeSessionFuture.setSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeStream(int streamID) {
|
private void removeStream(int streamId) {
|
||||||
spdySession.removeStream(streamID);
|
spdySession.removeStream(streamId);
|
||||||
if (closeSessionFuture != null && spdySession.noActiveStreams()) {
|
if (closeSessionFuture != null && spdySession.noActiveStreams()) {
|
||||||
closeSessionFuture.setSuccess();
|
closeSessionFuture.setSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSendWindowSize(ChannelHandlerContext ctx, final int streamID, int deltaWindowSize) {
|
private void updateSendWindowSize(ChannelHandlerContext ctx, final int streamId, int deltaWindowSize) {
|
||||||
synchronized (flowControlLock) {
|
synchronized (flowControlLock) {
|
||||||
int newWindowSize = spdySession.updateSendWindowSize(streamID, deltaWindowSize);
|
int newWindowSize = spdySession.updateSendWindowSize(streamId, deltaWindowSize);
|
||||||
|
|
||||||
while (newWindowSize > 0) {
|
while (newWindowSize > 0) {
|
||||||
// Check if we have unblocked a stalled stream
|
// Check if we have unblocked a stalled stream
|
||||||
MessageEvent e = spdySession.getPendingWrite(streamID);
|
MessageEvent e = spdySession.getPendingWrite(streamId);
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -778,8 +765,8 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
|
|
||||||
if (newWindowSize >= dataFrameSize) {
|
if (newWindowSize >= dataFrameSize) {
|
||||||
// Window size is large enough to send entire data frame
|
// Window size is large enough to send entire data frame
|
||||||
spdySession.removePendingWrite(streamID);
|
spdySession.removePendingWrite(streamId);
|
||||||
newWindowSize = spdySession.updateSendWindowSize(streamID, -1 * dataFrameSize);
|
newWindowSize = spdySession.updateSendWindowSize(streamId, -1 * dataFrameSize);
|
||||||
|
|
||||||
// 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 stream on write failures that leaves the transfer window in a corrupt state.
|
// Close the stream on write failures that leaves the transfer window in a corrupt state.
|
||||||
@ -788,23 +775,23 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
e.getFuture().addListener(new ChannelFutureListener() {
|
e.getFuture().addListener(new ChannelFutureListener() {
|
||||||
public void operationComplete(ChannelFuture future) throws Exception {
|
public void operationComplete(ChannelFuture future) throws Exception {
|
||||||
if (!future.isSuccess()) {
|
if (!future.isSuccess()) {
|
||||||
issueStreamError(context, remoteAddress, streamID, SpdyStreamStatus.INTERNAL_ERROR);
|
issueStreamError(context, remoteAddress, streamId, SpdyStreamStatus.INTERNAL_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Close the local side of the stream if this is the last frame
|
// Close the local side of the stream if this is the last frame
|
||||||
if (spdyDataFrame.isLast()) {
|
if (spdyDataFrame.isLast()) {
|
||||||
halfCloseStream(streamID, false);
|
halfCloseStream(streamId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Channels.write(ctx, e.getFuture(), spdyDataFrame, e.getRemoteAddress());
|
Channels.write(ctx, e.getFuture(), spdyDataFrame, e.getRemoteAddress());
|
||||||
} else {
|
} else {
|
||||||
// We can send a partial frame
|
// We can send a partial frame
|
||||||
spdySession.updateSendWindowSize(streamID, -1 * newWindowSize);
|
spdySession.updateSendWindowSize(streamId, -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(streamID);
|
SpdyDataFrame partialDataFrame = new DefaultSpdyDataFrame(streamId);
|
||||||
partialDataFrame.setData(spdyDataFrame.getData().readSlice(newWindowSize));
|
partialDataFrame.setData(spdyDataFrame.getData().readSlice(newWindowSize));
|
||||||
|
|
||||||
ChannelFuture writeFuture = Channels.future(e.getChannel());
|
ChannelFuture writeFuture = Channels.future(e.getChannel());
|
||||||
@ -816,7 +803,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
e.getFuture().addListener(new ChannelFutureListener() {
|
e.getFuture().addListener(new ChannelFutureListener() {
|
||||||
public void operationComplete(ChannelFuture future) throws Exception {
|
public void operationComplete(ChannelFuture future) throws Exception {
|
||||||
if (!future.isSuccess()) {
|
if (!future.isSuccess()) {
|
||||||
issueStreamError(context, remoteAddress, streamID, SpdyStreamStatus.INTERNAL_ERROR);
|
issueStreamError(context, remoteAddress, streamId, SpdyStreamStatus.INTERNAL_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -849,7 +836,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
|||||||
ChannelHandlerContext ctx, Channel channel, SocketAddress remoteAddress, SpdySessionStatus status) {
|
ChannelHandlerContext ctx, Channel channel, SocketAddress remoteAddress, SpdySessionStatus status) {
|
||||||
if (!sentGoAwayFrame) {
|
if (!sentGoAwayFrame) {
|
||||||
sentGoAwayFrame = true;
|
sentGoAwayFrame = true;
|
||||||
SpdyGoAwayFrame spdyGoAwayFrame = new DefaultSpdyGoAwayFrame(lastGoodStreamID, status);
|
SpdyGoAwayFrame spdyGoAwayFrame = new DefaultSpdyGoAwayFrame(lastGoodStreamId, status);
|
||||||
ChannelFuture future = Channels.future(channel);
|
ChannelFuture future = Channels.future(channel);
|
||||||
Channels.write(ctx, future, spdyGoAwayFrame, remoteAddress);
|
Channels.write(ctx, future, spdyGoAwayFrame, remoteAddress);
|
||||||
return future;
|
return future;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -18,9 +18,9 @@ package org.jboss.netty.handler.codec.spdy;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A SPDY Protocol SETTINGS Control Frame
|
* A SPDY Protocol SETTINGS Frame
|
||||||
*/
|
*/
|
||||||
public interface SpdySettingsFrame {
|
public interface SpdySettingsFrame extends SpdyFrame {
|
||||||
|
|
||||||
int SETTINGS_UPLOAD_BANDWIDTH = 1;
|
int SETTINGS_UPLOAD_BANDWIDTH = 1;
|
||||||
int SETTINGS_DOWNLOAD_BANDWIDTH = 2;
|
int SETTINGS_DOWNLOAD_BANDWIDTH = 2;
|
||||||
@ -31,12 +31,6 @@ public interface SpdySettingsFrame {
|
|||||||
int SETTINGS_INITIAL_WINDOW_SIZE = 7;
|
int SETTINGS_INITIAL_WINDOW_SIZE = 7;
|
||||||
int SETTINGS_CLIENT_CERTIFICATE_VECTOR_SIZE = 8;
|
int SETTINGS_CLIENT_CERTIFICATE_VECTOR_SIZE = 8;
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #getIds()} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
Set<Integer> getIDs();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@code Set} of the setting IDs.
|
* Returns a {@code Set} of the setting IDs.
|
||||||
* The set's iterator will return the IDs in ascending order.
|
* The set's iterator will return the IDs in ascending order.
|
||||||
@ -70,16 +64,10 @@ public interface SpdySettingsFrame {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the value of the setting ID.
|
* Removes the value of the setting ID.
|
||||||
* Removes all persistance information for the setting.
|
* Removes all persistence information for the setting.
|
||||||
*/
|
*/
|
||||||
void removeValue(int id);
|
void removeValue(int id);
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #isPersistValue(int)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
boolean persistValue(int id);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code true} if this setting should be persisted.
|
* Returns {@code true} if this setting should be persisted.
|
||||||
* Returns {@code false} if this setting should not be persisted
|
* Returns {@code false} if this setting should not be persisted
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -16,12 +16,28 @@
|
|||||||
package org.jboss.netty.handler.codec.spdy;
|
package org.jboss.netty.handler.codec.spdy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default {@link SpdyNoOpFrame} implementation.
|
* A SPDY Protocol Frame that is associated with an individual SPDY Stream
|
||||||
*/
|
*/
|
||||||
public class DefaultSpdyNoOpFrame implements SpdyNoOpFrame {
|
public interface SpdyStreamFrame extends SpdyFrame {
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public String toString() {
|
* Returns the Stream-ID of this frame.
|
||||||
return getClass().getSimpleName();
|
*/
|
||||||
}
|
int getStreamId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the Stream-ID of this frame. The Stream-ID must be positive.
|
||||||
|
*/
|
||||||
|
void setStreamId(int streamId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@code true} if this frame is the last frame to be transmitted
|
||||||
|
* on the stream.
|
||||||
|
*/
|
||||||
|
boolean isLast();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets if this frame is the last frame to be transmitted on the stream.
|
||||||
|
*/
|
||||||
|
void setLast(boolean last);
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -16,40 +16,8 @@
|
|||||||
package org.jboss.netty.handler.codec.spdy;
|
package org.jboss.netty.handler.codec.spdy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A SPDY Protocol SYN_REPLY Control Frame
|
* A SPDY Protocol SYN_REPLY Frame
|
||||||
*/
|
*/
|
||||||
public interface SpdySynReplyFrame extends SpdyHeaderBlock {
|
public interface SpdySynReplyFrame extends SpdyHeadersFrame {
|
||||||
|
// Tag interface
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #getStreamId()} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
int getStreamID();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the Stream-ID of this frame.
|
|
||||||
*/
|
|
||||||
int getStreamId();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #setStreamId(int)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
void setStreamID(int streamID);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the Stream-ID of this frame. The Stream-ID must be positive.
|
|
||||||
*/
|
|
||||||
void setStreamId(int streamID);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns {@code true} if this frame is the last frame to be transmitted
|
|
||||||
* on the stream.
|
|
||||||
*/
|
|
||||||
boolean isLast();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets if this frame is the last frame to be transmitted on the stream.
|
|
||||||
*/
|
|
||||||
void setLast(boolean last);
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -16,49 +16,15 @@
|
|||||||
package org.jboss.netty.handler.codec.spdy;
|
package org.jboss.netty.handler.codec.spdy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A SPDY Protocol SYN_STREAM Control Frame
|
* A SPDY Protocol SYN_STREAM Frame
|
||||||
*/
|
*/
|
||||||
public interface SpdySynStreamFrame extends SpdyHeaderBlock {
|
public interface SpdySynStreamFrame extends SpdyHeadersFrame {
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #getStreamId()} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
int getStreamID();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the Stream-ID of this frame.
|
|
||||||
*/
|
|
||||||
int getStreamId();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #setStreamId(int)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
void setStreamID(int streamID);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the Stream-ID of this frame. The Stream-ID must be positive.
|
|
||||||
*/
|
|
||||||
void setStreamId(int streamId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #getAssociatedToStreamId()} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
int getAssociatedToStreamID();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Associated-To-Stream-ID of this frame.
|
* Returns the Associated-To-Stream-ID of this frame.
|
||||||
*/
|
*/
|
||||||
int getAssociatedToStreamId();
|
int getAssociatedToStreamId();
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #setAssociatedToStreamId(int)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
void setAssociatedToStreamID(int associatedToStreamId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the Associated-To-Stream-ID of this frame.
|
* Sets the Associated-To-Stream-ID of this frame.
|
||||||
* The Associated-To-Stream-ID cannot be negative.
|
* The Associated-To-Stream-ID cannot be negative.
|
||||||
@ -76,17 +42,6 @@ public interface SpdySynStreamFrame extends SpdyHeaderBlock {
|
|||||||
*/
|
*/
|
||||||
void setPriority(byte priority);
|
void setPriority(byte priority);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns {@code true} if this frame is the last frame to be transmitted
|
|
||||||
* on the stream.
|
|
||||||
*/
|
|
||||||
boolean isLast();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets if this frame is the last frame to be transmitted on the stream.
|
|
||||||
*/
|
|
||||||
void setLast(boolean last);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code true} if the stream created with this frame is to be
|
* Returns {@code true} if the stream created with this frame is to be
|
||||||
* considered half-closed to the receiver.
|
* considered half-closed to the receiver.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -16,15 +16,9 @@
|
|||||||
package org.jboss.netty.handler.codec.spdy;
|
package org.jboss.netty.handler.codec.spdy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A SPDY Protocol WINDOW_UPDATE Control Frame
|
* A SPDY Protocol WINDOW_UPDATE Frame
|
||||||
*/
|
*/
|
||||||
public interface SpdyWindowUpdateFrame {
|
public interface SpdyWindowUpdateFrame extends SpdyFrame {
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #getStreamId()} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
int getStreamID();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Stream-ID of this frame.
|
* Returns the Stream-ID of this frame.
|
||||||
@ -32,12 +26,7 @@ public interface SpdyWindowUpdateFrame {
|
|||||||
int getStreamId();
|
int getStreamId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use {@link #setStreamId(int)} instead.
|
* Sets the Stream-ID of this frame. The Stream-ID cannot be negative.
|
||||||
*/
|
|
||||||
void setStreamID(int streamId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the Stream-ID of this frame. The Stream-ID must be positive.
|
|
||||||
*/
|
*/
|
||||||
void setStreamId(int streamId);
|
void setStreamId(int streamId);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 The Netty Project
|
* Copyright 2013 The Netty Project
|
||||||
*
|
*
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
* The Netty Project licenses this file to you under the Apache License,
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||||
@ -38,40 +38,25 @@ public class SpdySessionHandlerTest {
|
|||||||
closeMessage.setValue(closeSignal, 0);
|
closeMessage.setValue(closeSignal, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertHeaderBlock(SpdyHeaderBlock received, SpdyHeaderBlock expected) {
|
private static void assertDataFrame(Object msg, int streamId, boolean last) {
|
||||||
for (String name: expected.getHeaderNames()) {
|
|
||||||
List<String> expectedValues = expected.getHeaders(name);
|
|
||||||
List<String> receivedValues = received.getHeaders(name);
|
|
||||||
assertTrue(receivedValues.containsAll(expectedValues));
|
|
||||||
receivedValues.removeAll(expectedValues);
|
|
||||||
assertTrue(receivedValues.isEmpty());
|
|
||||||
received.removeHeader(name);
|
|
||||||
}
|
|
||||||
assertTrue(received.getHeaders().isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void assertDataFrame(Object msg, int streamID, boolean last) {
|
|
||||||
assertNotNull(msg);
|
assertNotNull(msg);
|
||||||
assertTrue(msg instanceof SpdyDataFrame);
|
assertTrue(msg instanceof SpdyDataFrame);
|
||||||
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
|
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
|
||||||
assertEquals(spdyDataFrame.getStreamId(), streamID);
|
assertEquals(spdyDataFrame.getStreamId(), streamId);
|
||||||
assertEquals(spdyDataFrame.isLast(), last);
|
assertEquals(spdyDataFrame.isLast(), last);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertSynReply(Object msg, int streamID, boolean last, SpdyHeaderBlock headers) {
|
private static void assertSynReply(Object msg, int streamId, boolean last, SpdyHeadersFrame headers) {
|
||||||
assertNotNull(msg);
|
assertNotNull(msg);
|
||||||
assertTrue(msg instanceof SpdySynReplyFrame);
|
assertTrue(msg instanceof SpdySynReplyFrame);
|
||||||
SpdySynReplyFrame spdySynReplyFrame = (SpdySynReplyFrame) msg;
|
assertHeaders(msg, streamId, last, headers);
|
||||||
assertEquals(spdySynReplyFrame.getStreamId(), streamID);
|
|
||||||
assertEquals(spdySynReplyFrame.isLast(), last);
|
|
||||||
assertHeaderBlock(spdySynReplyFrame, headers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertRstStream(Object msg, int streamID, SpdyStreamStatus status) {
|
private static void assertRstStream(Object msg, int streamId, SpdyStreamStatus status) {
|
||||||
assertNotNull(msg);
|
assertNotNull(msg);
|
||||||
assertTrue(msg instanceof SpdyRstStreamFrame);
|
assertTrue(msg instanceof SpdyRstStreamFrame);
|
||||||
SpdyRstStreamFrame spdyRstStreamFrame = (SpdyRstStreamFrame) msg;
|
SpdyRstStreamFrame spdyRstStreamFrame = (SpdyRstStreamFrame) msg;
|
||||||
assertEquals(spdyRstStreamFrame.getStreamId(), streamID);
|
assertEquals(spdyRstStreamFrame.getStreamId(), streamId);
|
||||||
assertEquals(spdyRstStreamFrame.getStatus(), status);
|
assertEquals(spdyRstStreamFrame.getStatus(), status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,19 +67,28 @@ public class SpdySessionHandlerTest {
|
|||||||
assertEquals(spdyPingFrame.getId(), id);
|
assertEquals(spdyPingFrame.getId(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertGoAway(Object msg, int lastGoodStreamID) {
|
private static void assertGoAway(Object msg, int lastGoodStreamId) {
|
||||||
assertNotNull(msg);
|
assertNotNull(msg);
|
||||||
assertTrue(msg instanceof SpdyGoAwayFrame);
|
assertTrue(msg instanceof SpdyGoAwayFrame);
|
||||||
SpdyGoAwayFrame spdyGoAwayFrame = (SpdyGoAwayFrame) msg;
|
SpdyGoAwayFrame spdyGoAwayFrame = (SpdyGoAwayFrame) msg;
|
||||||
assertEquals(spdyGoAwayFrame.getLastGoodStreamId(), lastGoodStreamID);
|
assertEquals(spdyGoAwayFrame.getLastGoodStreamId(), lastGoodStreamId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertHeaders(Object msg, int streamID, SpdyHeaderBlock headers) {
|
private static void assertHeaders(Object msg, int streamId, boolean last, SpdyHeadersFrame headers) {
|
||||||
assertNotNull(msg);
|
assertNotNull(msg);
|
||||||
assertTrue(msg instanceof SpdyHeadersFrame);
|
assertTrue(msg instanceof SpdyHeadersFrame);
|
||||||
SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg;
|
SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg;
|
||||||
assertEquals(spdyHeadersFrame.getStreamId(), streamID);
|
assertEquals(spdyHeadersFrame.getStreamId(), streamId);
|
||||||
assertHeaderBlock(spdyHeadersFrame, headers);
|
assertEquals(spdyHeadersFrame.isLast(), last);
|
||||||
|
for (String name: headers.getHeaderNames()) {
|
||||||
|
List<String> expectedValues = headers.getHeaders(name);
|
||||||
|
List<String> receivedValues = spdyHeadersFrame.getHeaders(name);
|
||||||
|
assertTrue(receivedValues.containsAll(expectedValues));
|
||||||
|
receivedValues.removeAll(expectedValues);
|
||||||
|
assertTrue(receivedValues.isEmpty());
|
||||||
|
spdyHeadersFrame.removeHeader(name);
|
||||||
|
}
|
||||||
|
assertTrue(spdyHeadersFrame.getHeaders().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void testSpdySessionHandler(int version, boolean server) {
|
private static void testSpdySessionHandler(int version, boolean server) {
|
||||||
@ -103,68 +97,68 @@ public class SpdySessionHandlerTest {
|
|||||||
new SpdySessionHandler(version, server), new EchoHandler(closeSignal, server));
|
new SpdySessionHandler(version, server), new EchoHandler(closeSignal, server));
|
||||||
sessionHandler.pollAll();
|
sessionHandler.pollAll();
|
||||||
|
|
||||||
int localStreamID = server ? 1 : 2;
|
int localStreamId = server ? 1 : 2;
|
||||||
int remoteStreamID = server ? 2 : 1;
|
int remoteStreamId = server ? 2 : 1;
|
||||||
|
|
||||||
SpdyPingFrame localPingFrame = new DefaultSpdyPingFrame(localStreamID);
|
SpdyPingFrame localPingFrame = new DefaultSpdyPingFrame(localStreamId);
|
||||||
SpdyPingFrame remotePingFrame = new DefaultSpdyPingFrame(remoteStreamID);
|
SpdyPingFrame remotePingFrame = new DefaultSpdyPingFrame(remoteStreamId);
|
||||||
|
|
||||||
SpdySynStreamFrame spdySynStreamFrame =
|
SpdySynStreamFrame spdySynStreamFrame =
|
||||||
new DefaultSpdySynStreamFrame(localStreamID, 0, (byte) 0);
|
new DefaultSpdySynStreamFrame(localStreamId, 0, (byte) 0);
|
||||||
spdySynStreamFrame.setHeader("Compression", "test");
|
spdySynStreamFrame.setHeader("Compression", "test");
|
||||||
|
|
||||||
SpdyDataFrame spdyDataFrame = new DefaultSpdyDataFrame(localStreamID);
|
SpdyDataFrame spdyDataFrame = new DefaultSpdyDataFrame(localStreamId);
|
||||||
spdyDataFrame.setLast(true);
|
spdyDataFrame.setLast(true);
|
||||||
|
|
||||||
// Check if session handler returns INVALID_STREAM if it receives
|
// Check if session handler returns INVALID_STREAM if it receives
|
||||||
// a data frame for a Stream-ID that is not open
|
// a data frame for a Stream-ID that is not open
|
||||||
sessionHandler.offer(new DefaultSpdyDataFrame(localStreamID));
|
sessionHandler.offer(new DefaultSpdyDataFrame(localStreamId));
|
||||||
assertRstStream(sessionHandler.poll(), localStreamID, SpdyStreamStatus.INVALID_STREAM);
|
assertRstStream(sessionHandler.poll(), localStreamId, SpdyStreamStatus.INVALID_STREAM);
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
|
|
||||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||||
// a data frame for a Stream-ID before receiving a SYN_REPLY frame
|
// a data frame for a Stream-ID before receiving a SYN_REPLY frame
|
||||||
sessionHandler.offer(new DefaultSpdyDataFrame(remoteStreamID));
|
sessionHandler.offer(new DefaultSpdyDataFrame(remoteStreamId));
|
||||||
assertRstStream(sessionHandler.poll(), remoteStreamID, SpdyStreamStatus.PROTOCOL_ERROR);
|
assertRstStream(sessionHandler.poll(), remoteStreamId, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
remoteStreamID += 2;
|
remoteStreamId += 2;
|
||||||
|
|
||||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||||
// multiple SYN_REPLY frames for the same active Stream-ID
|
// multiple SYN_REPLY frames for the same active Stream-ID
|
||||||
sessionHandler.offer(new DefaultSpdySynReplyFrame(remoteStreamID));
|
sessionHandler.offer(new DefaultSpdySynReplyFrame(remoteStreamId));
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
sessionHandler.offer(new DefaultSpdySynReplyFrame(remoteStreamID));
|
sessionHandler.offer(new DefaultSpdySynReplyFrame(remoteStreamId));
|
||||||
assertRstStream(sessionHandler.poll(), remoteStreamID, SpdyStreamStatus.STREAM_IN_USE);
|
assertRstStream(sessionHandler.poll(), remoteStreamId, SpdyStreamStatus.STREAM_IN_USE);
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
remoteStreamID += 2;
|
remoteStreamId += 2;
|
||||||
|
|
||||||
// Check if frame codec correctly compresses/uncompresses headers
|
// Check if frame codec correctly compresses/uncompresses headers
|
||||||
sessionHandler.offer(spdySynStreamFrame);
|
sessionHandler.offer(spdySynStreamFrame);
|
||||||
assertSynReply(sessionHandler.poll(), localStreamID, false, spdySynStreamFrame);
|
assertSynReply(sessionHandler.poll(), localStreamId, false, spdySynStreamFrame);
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
SpdyHeadersFrame spdyHeadersFrame = new DefaultSpdyHeadersFrame(localStreamID);
|
SpdyHeadersFrame spdyHeadersFrame = new DefaultSpdyHeadersFrame(localStreamId);
|
||||||
spdyHeadersFrame.addHeader("HEADER","test1");
|
spdyHeadersFrame.addHeader("HEADER","test1");
|
||||||
spdyHeadersFrame.addHeader("HEADER","test2");
|
spdyHeadersFrame.addHeader("HEADER","test2");
|
||||||
sessionHandler.offer(spdyHeadersFrame);
|
sessionHandler.offer(spdyHeadersFrame);
|
||||||
assertHeaders(sessionHandler.poll(), localStreamID, spdyHeadersFrame);
|
assertHeaders(sessionHandler.poll(), localStreamId, false, spdyHeadersFrame);
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
localStreamID += 2;
|
localStreamId += 2;
|
||||||
|
|
||||||
// Check if session handler closed the streams using the number
|
// Check if session handler closed the streams using the number
|
||||||
// of concurrent streams and that it returns REFUSED_STREAM
|
// of concurrent streams and that it returns REFUSED_STREAM
|
||||||
// if it receives a SYN_STREAM frame it does not wish to accept
|
// if it receives a SYN_STREAM frame it does not wish to accept
|
||||||
spdySynStreamFrame.setStreamId(localStreamID);
|
spdySynStreamFrame.setStreamId(localStreamId);
|
||||||
spdySynStreamFrame.setLast(true);
|
spdySynStreamFrame.setLast(true);
|
||||||
spdySynStreamFrame.setUnidirectional(true);
|
spdySynStreamFrame.setUnidirectional(true);
|
||||||
sessionHandler.offer(spdySynStreamFrame);
|
sessionHandler.offer(spdySynStreamFrame);
|
||||||
assertRstStream(sessionHandler.poll(), localStreamID, SpdyStreamStatus.REFUSED_STREAM);
|
assertRstStream(sessionHandler.poll(), localStreamId, SpdyStreamStatus.REFUSED_STREAM);
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
|
|
||||||
// Check if session handler drops active streams if it receives
|
// Check if session handler drops active streams if it receives
|
||||||
// a RST_STREAM frame for that Stream-ID
|
// a RST_STREAM frame for that Stream-ID
|
||||||
sessionHandler.offer(new DefaultSpdyRstStreamFrame(remoteStreamID, 3));
|
sessionHandler.offer(new DefaultSpdyRstStreamFrame(remoteStreamId, 3));
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
remoteStreamID += 2;
|
remoteStreamId += 2;
|
||||||
|
|
||||||
// Check if session handler honors UNIDIRECTIONAL streams
|
// Check if session handler honors UNIDIRECTIONAL streams
|
||||||
spdySynStreamFrame.setLast(false);
|
spdySynStreamFrame.setLast(false);
|
||||||
@ -175,17 +169,17 @@ public class SpdySessionHandlerTest {
|
|||||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||||
// multiple SYN_STREAM frames for the same active Stream-ID
|
// multiple SYN_STREAM frames for the same active Stream-ID
|
||||||
sessionHandler.offer(spdySynStreamFrame);
|
sessionHandler.offer(spdySynStreamFrame);
|
||||||
assertRstStream(sessionHandler.poll(), localStreamID, SpdyStreamStatus.PROTOCOL_ERROR);
|
assertRstStream(sessionHandler.poll(), localStreamId, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
localStreamID += 2;
|
localStreamId += 2;
|
||||||
|
|
||||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||||
// a SYN_STREAM frame with an invalid Stream-ID
|
// a SYN_STREAM frame with an invalid Stream-ID
|
||||||
spdySynStreamFrame.setStreamId(localStreamID - 1);
|
spdySynStreamFrame.setStreamId(localStreamId - 1);
|
||||||
sessionHandler.offer(spdySynStreamFrame);
|
sessionHandler.offer(spdySynStreamFrame);
|
||||||
assertRstStream(sessionHandler.poll(), localStreamID - 1, SpdyStreamStatus.PROTOCOL_ERROR);
|
assertRstStream(sessionHandler.poll(), localStreamId - 1, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
spdySynStreamFrame.setStreamId(localStreamID);
|
spdySynStreamFrame.setStreamId(localStreamId);
|
||||||
|
|
||||||
// Check if session handler correctly limits the number of
|
// Check if session handler correctly limits the number of
|
||||||
// concurrent streams in the SETTINGS frame
|
// concurrent streams in the SETTINGS frame
|
||||||
@ -194,31 +188,31 @@ public class SpdySessionHandlerTest {
|
|||||||
sessionHandler.offer(spdySettingsFrame);
|
sessionHandler.offer(spdySettingsFrame);
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
sessionHandler.offer(spdySynStreamFrame);
|
sessionHandler.offer(spdySynStreamFrame);
|
||||||
assertRstStream(sessionHandler.poll(), localStreamID, SpdyStreamStatus.REFUSED_STREAM);
|
assertRstStream(sessionHandler.poll(), localStreamId, SpdyStreamStatus.REFUSED_STREAM);
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
spdySettingsFrame.setValue(SpdySettingsFrame.SETTINGS_MAX_CONCURRENT_STREAMS, 4);
|
spdySettingsFrame.setValue(SpdySettingsFrame.SETTINGS_MAX_CONCURRENT_STREAMS, 4);
|
||||||
sessionHandler.offer(spdySettingsFrame);
|
sessionHandler.offer(spdySettingsFrame);
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
sessionHandler.offer(spdySynStreamFrame);
|
sessionHandler.offer(spdySynStreamFrame);
|
||||||
assertSynReply(sessionHandler.poll(), localStreamID, false, spdySynStreamFrame);
|
assertSynReply(sessionHandler.poll(), localStreamId, false, spdySynStreamFrame);
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
|
|
||||||
// Check if session handler rejects HEADERS for closed streams
|
// Check if session handler rejects HEADERS for closed streams
|
||||||
int testStreamID = spdyDataFrame.getStreamId();
|
int testStreamId = spdyDataFrame.getStreamId();
|
||||||
sessionHandler.offer(spdyDataFrame);
|
sessionHandler.offer(spdyDataFrame);
|
||||||
assertDataFrame(sessionHandler.poll(), testStreamID, spdyDataFrame.isLast());
|
assertDataFrame(sessionHandler.poll(), testStreamId, spdyDataFrame.isLast());
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
spdyHeadersFrame.setStreamId(testStreamID);
|
spdyHeadersFrame.setStreamId(testStreamId);
|
||||||
sessionHandler.offer(spdyHeadersFrame);
|
sessionHandler.offer(spdyHeadersFrame);
|
||||||
assertRstStream(sessionHandler.poll(), testStreamID, SpdyStreamStatus.INVALID_STREAM);
|
assertRstStream(sessionHandler.poll(), testStreamId, SpdyStreamStatus.INVALID_STREAM);
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
|
|
||||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||||
// an invalid HEADERS frame
|
// an invalid HEADERS frame
|
||||||
spdyHeadersFrame.setStreamId(localStreamID);
|
spdyHeadersFrame.setStreamId(localStreamId);
|
||||||
spdyHeadersFrame.setInvalid();
|
spdyHeadersFrame.setInvalid();
|
||||||
sessionHandler.offer(spdyHeadersFrame);
|
sessionHandler.offer(spdyHeadersFrame);
|
||||||
assertRstStream(sessionHandler.poll(), localStreamID, SpdyStreamStatus.PROTOCOL_ERROR);
|
assertRstStream(sessionHandler.poll(), localStreamId, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
|
|
||||||
// Check if session handler returns identical local PINGs
|
// Check if session handler returns identical local PINGs
|
||||||
@ -232,20 +226,20 @@ public class SpdySessionHandlerTest {
|
|||||||
|
|
||||||
// Check if session handler sends a GOAWAY frame when closing
|
// Check if session handler sends a GOAWAY frame when closing
|
||||||
sessionHandler.offer(closeMessage);
|
sessionHandler.offer(closeMessage);
|
||||||
assertGoAway(sessionHandler.poll(), localStreamID);
|
assertGoAway(sessionHandler.poll(), localStreamId);
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
localStreamID += 2;
|
localStreamId += 2;
|
||||||
|
|
||||||
// Check if session handler returns REFUSED_STREAM if it receives
|
// Check if session handler returns REFUSED_STREAM if it receives
|
||||||
// SYN_STREAM frames after sending a GOAWAY frame
|
// SYN_STREAM frames after sending a GOAWAY frame
|
||||||
spdySynStreamFrame.setStreamId(localStreamID);
|
spdySynStreamFrame.setStreamId(localStreamId);
|
||||||
sessionHandler.offer(spdySynStreamFrame);
|
sessionHandler.offer(spdySynStreamFrame);
|
||||||
assertRstStream(sessionHandler.poll(), localStreamID, SpdyStreamStatus.REFUSED_STREAM);
|
assertRstStream(sessionHandler.poll(), localStreamId, SpdyStreamStatus.REFUSED_STREAM);
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
|
|
||||||
// Check if session handler ignores Data frames after sending
|
// Check if session handler ignores Data frames after sending
|
||||||
// a GOAWAY frame
|
// a GOAWAY frame
|
||||||
spdyDataFrame.setStreamId(localStreamID);
|
spdyDataFrame.setStreamId(localStreamId);
|
||||||
sessionHandler.offer(spdyDataFrame);
|
sessionHandler.offer(spdyDataFrame);
|
||||||
assertNull(sessionHandler.peek());
|
assertNull(sessionHandler.peek());
|
||||||
|
|
||||||
@ -282,9 +276,9 @@ public class SpdySessionHandlerTest {
|
|||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
// Initiate 4 new streams
|
// Initiate 4 new streams
|
||||||
int streamID = server ? 2 : 1;
|
int streamId = server ? 2 : 1;
|
||||||
SpdySynStreamFrame spdySynStreamFrame =
|
SpdySynStreamFrame spdySynStreamFrame =
|
||||||
new DefaultSpdySynStreamFrame(streamID, 0, (byte) 0);
|
new DefaultSpdySynStreamFrame(streamId, 0, (byte) 0);
|
||||||
spdySynStreamFrame.setLast(true);
|
spdySynStreamFrame.setLast(true);
|
||||||
Channels.write(e.getChannel(), spdySynStreamFrame);
|
Channels.write(e.getChannel(), spdySynStreamFrame);
|
||||||
spdySynStreamFrame.setStreamId(spdySynStreamFrame.getStreamId() + 2);
|
spdySynStreamFrame.setStreamId(spdySynStreamFrame.getStreamId() + 2);
|
||||||
@ -304,20 +298,12 @@ public class SpdySessionHandlerTest {
|
|||||||
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
|
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Object msg = e.getMessage();
|
Object msg = e.getMessage();
|
||||||
if (msg instanceof SpdyDataFrame ||
|
|
||||||
msg instanceof SpdyPingFrame ||
|
|
||||||
msg instanceof SpdyHeadersFrame) {
|
|
||||||
|
|
||||||
Channels.write(e.getChannel(), msg, e.getRemoteAddress());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg instanceof SpdySynStreamFrame) {
|
if (msg instanceof SpdySynStreamFrame) {
|
||||||
|
|
||||||
SpdySynStreamFrame spdySynStreamFrame = (SpdySynStreamFrame) msg;
|
SpdySynStreamFrame spdySynStreamFrame = (SpdySynStreamFrame) msg;
|
||||||
|
|
||||||
int streamID = spdySynStreamFrame.getStreamId();
|
int streamId = spdySynStreamFrame.getStreamId();
|
||||||
SpdySynReplyFrame spdySynReplyFrame = new DefaultSpdySynReplyFrame(streamID);
|
SpdySynReplyFrame spdySynReplyFrame = new DefaultSpdySynReplyFrame(streamId);
|
||||||
spdySynReplyFrame.setLast(spdySynStreamFrame.isLast());
|
spdySynReplyFrame.setLast(spdySynStreamFrame.isLast());
|
||||||
for (Map.Entry<String, String> entry: spdySynStreamFrame.getHeaders()) {
|
for (Map.Entry<String, String> entry: spdySynStreamFrame.getHeaders()) {
|
||||||
spdySynReplyFrame.addHeader(entry.getKey(), entry.getValue());
|
spdySynReplyFrame.addHeader(entry.getKey(), entry.getValue());
|
||||||
@ -327,6 +313,18 @@ public class SpdySessionHandlerTest {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (msg instanceof SpdySynReplyFrame) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg instanceof SpdyDataFrame ||
|
||||||
|
msg instanceof SpdyPingFrame ||
|
||||||
|
msg instanceof SpdyHeadersFrame) {
|
||||||
|
|
||||||
|
Channels.write(e.getChannel(), msg, e.getRemoteAddress());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (msg instanceof SpdySettingsFrame) {
|
if (msg instanceof SpdySettingsFrame) {
|
||||||
|
|
||||||
SpdySettingsFrame spdySettingsFrame = (SpdySettingsFrame) msg;
|
SpdySettingsFrame spdySettingsFrame = (SpdySettingsFrame) msg;
|
||||||
|
Loading…
Reference in New Issue
Block a user