[#691] Correctly handle SpdyRstStreamFrame
This commit is contained in:
parent
e726ff63d9
commit
4696fcde1f
@ -20,6 +20,7 @@ import java.util.Queue;
|
|||||||
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.handler.codec.MessageToMessageCodec;
|
import io.netty.handler.codec.MessageToMessageCodec;
|
||||||
|
import io.netty.handler.codec.http.HttpMessage;
|
||||||
import io.netty.handler.codec.http.HttpRequest;
|
import io.netty.handler.codec.http.HttpRequest;
|
||||||
import io.netty.handler.codec.http.HttpResponse;
|
import io.netty.handler.codec.http.HttpResponse;
|
||||||
|
|
||||||
@ -29,22 +30,27 @@ import io.netty.handler.codec.http.HttpResponse;
|
|||||||
* for HTTP.
|
* for HTTP.
|
||||||
*/
|
*/
|
||||||
public class SpdyHttpResponseStreamIdHandler extends
|
public class SpdyHttpResponseStreamIdHandler extends
|
||||||
MessageToMessageCodec<HttpRequest, HttpRequest, HttpResponse, HttpResponse> {
|
MessageToMessageCodec<HttpRequest, HttpRequest, Object, Object> {
|
||||||
private static final Integer NO_ID = -1;
|
private static final Integer NO_ID = -1;
|
||||||
private final Queue<Integer> ids = new LinkedList<Integer>();
|
private final Queue<Integer> ids = new LinkedList<Integer>();
|
||||||
|
|
||||||
public SpdyHttpResponseStreamIdHandler() {
|
public SpdyHttpResponseStreamIdHandler() {
|
||||||
super(new Class<?>[] { HttpRequest.class }, new Class<?>[] { HttpResponse.class });
|
super(new Class<?>[] { HttpRequest.class, SpdyRstStreamFrame.class }, new Class<?>[] { HttpResponse.class });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpResponse encode(ChannelHandlerContext ctx, HttpResponse msg) throws Exception {
|
public Object encode(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||||
boolean contains = msg.containsHeader(SpdyHttpHeaders.Names.STREAM_ID);
|
if (msg instanceof HttpMessage) {
|
||||||
|
boolean contains = ((HttpMessage)msg).containsHeader(SpdyHttpHeaders.Names.STREAM_ID);
|
||||||
if (!contains) {
|
if (!contains) {
|
||||||
ids.add(NO_ID);
|
ids.add(NO_ID);
|
||||||
} else {
|
} else {
|
||||||
ids.add(SpdyHttpHeaders.getStreamId(msg));
|
ids.add(SpdyHttpHeaders.getStreamId((HttpMessage) msg));
|
||||||
}
|
}
|
||||||
|
} else if (msg instanceof SpdyRstStreamFrame) {
|
||||||
|
ids.remove(((SpdyRstStreamFrame)msg).getStreamId());
|
||||||
|
}
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user