Renaming "Observer" to "Listener" for consistency in HTTP/2
Motivation: We currently have a mix of "Observer" and "Listener" for interface names. We should make them all "Listener" to be consistent. Modifications: Renamed Http2DataObserver->Http2DataListener and Http2FrameObserver->Http2FrameListener. Result: Listener interface names are consistent.
This commit is contained in:
parent
63d5925d6e
commit
102e781715
@ -45,7 +45,7 @@ import java.util.List;
|
|||||||
* as well as management of connection state and flow control for both inbound and outbound data
|
* as well as management of connection state and flow control for both inbound and outbound data
|
||||||
* frames.
|
* frames.
|
||||||
* <p>
|
* <p>
|
||||||
* Subclasses need to implement the methods defined by the {@link Http2FrameObserver} interface for
|
* Subclasses need to implement the methods defined by the {@link Http2FrameListener} interface for
|
||||||
* receiving inbound frames. Outbound frames are sent via one of the {@code writeXXX} methods.
|
* receiving inbound frames. Outbound frames are sent via one of the {@code writeXXX} methods.
|
||||||
* <p>
|
* <p>
|
||||||
* It should be noted that the connection preface is sent upon either activation or addition of this
|
* It should be noted that the connection preface is sent upon either activation or addition of this
|
||||||
@ -53,9 +53,9 @@ import java.util.List;
|
|||||||
* must call this class to write the preface to the remote endpoint.
|
* must call this class to write the preface to the remote endpoint.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractHttp2ConnectionHandler extends ByteToMessageDecoder implements
|
public abstract class AbstractHttp2ConnectionHandler extends ByteToMessageDecoder implements
|
||||||
Http2FrameObserver {
|
Http2FrameListener {
|
||||||
|
|
||||||
private final Http2FrameObserver internalFrameObserver = new FrameReadObserver();
|
private final Http2FrameListener internalFrameListener = new FrameReadListener();
|
||||||
private final Http2FrameReader frameReader;
|
private final Http2FrameReader frameReader;
|
||||||
private final Http2FrameWriter frameWriter;
|
private final Http2FrameWriter frameWriter;
|
||||||
private final Http2Connection connection;
|
private final Http2Connection connection;
|
||||||
@ -539,7 +539,7 @@ public abstract class AbstractHttp2ConnectionHandler extends ByteToMessageDecode
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
frameReader.readFrame(ctx, in, internalFrameObserver);
|
frameReader.readFrame(ctx, in, internalFrameListener);
|
||||||
} catch (Http2Exception e) {
|
} catch (Http2Exception e) {
|
||||||
onHttp2Exception(ctx, e);
|
onHttp2Exception(ctx, e);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
@ -812,7 +812,7 @@ public abstract class AbstractHttp2ConnectionHandler extends ByteToMessageDecode
|
|||||||
/**
|
/**
|
||||||
* Handles all inbound frames from the network.
|
* Handles all inbound frames from the network.
|
||||||
*/
|
*/
|
||||||
private final class FrameReadObserver implements Http2FrameObserver {
|
private final class FrameReadListener implements Http2FrameListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDataRead(final ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding,
|
public void onDataRead(final ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding,
|
||||||
|
@ -153,7 +153,7 @@ public class DefaultHttp2Connection implements Http2Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void removeStream(DefaultStream stream) {
|
private void removeStream(DefaultStream stream) {
|
||||||
// Notify the observers of the event first.
|
// Notify the listeners of the event first.
|
||||||
for (Listener listener : listeners) {
|
for (Listener listener : listeners) {
|
||||||
listener.streamRemoved(stream);
|
listener.streamRemoved(stream);
|
||||||
}
|
}
|
||||||
@ -724,7 +724,7 @@ public class DefaultHttp2Connection implements Http2Connection {
|
|||||||
List<ParentChangedEvent> events = new ArrayList<ParentChangedEvent>(1);
|
List<ParentChangedEvent> events = new ArrayList<ParentChangedEvent>(1);
|
||||||
connectionStream.takeChild(stream, false, events);
|
connectionStream.takeChild(stream, false, events);
|
||||||
|
|
||||||
// Notify the observers of the event.
|
// Notify the listeners of the event.
|
||||||
for (Listener listener : listeners) {
|
for (Listener listener : listeners) {
|
||||||
listener.streamAdded(stream);
|
listener.streamAdded(stream);
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ public class DefaultHttp2FrameReader implements Http2FrameReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFrame(ChannelHandlerContext ctx, ByteBuf input, Http2FrameObserver observer)
|
public void readFrame(ChannelHandlerContext ctx, ByteBuf input, Http2FrameListener listener)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
try {
|
try {
|
||||||
while (input.isReadable()) {
|
while (input.isReadable()) {
|
||||||
@ -126,7 +126,7 @@ public class DefaultHttp2FrameReader implements Http2FrameReader {
|
|||||||
// available, causing us to exit the loop. Instead, we just want to perform
|
// available, causing us to exit the loop. Instead, we just want to perform
|
||||||
// the first pass at payload processing now.
|
// the first pass at payload processing now.
|
||||||
case FRAME_PAYLOAD:
|
case FRAME_PAYLOAD:
|
||||||
processPayloadState(ctx, input, observer);
|
processPayloadState(ctx, input, listener);
|
||||||
if (state == State.FRAME_PAYLOAD) {
|
if (state == State.FRAME_PAYLOAD) {
|
||||||
// Wait until the entire payload has arrived.
|
// Wait until the entire payload has arrived.
|
||||||
return;
|
return;
|
||||||
@ -206,7 +206,7 @@ public class DefaultHttp2FrameReader implements Http2FrameReader {
|
|||||||
state = State.FRAME_PAYLOAD;
|
state = State.FRAME_PAYLOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processPayloadState(ChannelHandlerContext ctx, ByteBuf in, Http2FrameObserver observer)
|
private void processPayloadState(ChannelHandlerContext ctx, ByteBuf in, Http2FrameListener listener)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
if (in.readableBytes() < payloadLength) {
|
if (in.readableBytes() < payloadLength) {
|
||||||
// Wait until the entire payload has been read.
|
// Wait until the entire payload has been read.
|
||||||
@ -216,40 +216,40 @@ public class DefaultHttp2FrameReader implements Http2FrameReader {
|
|||||||
// Get a view of the buffer for the size of the payload.
|
// Get a view of the buffer for the size of the payload.
|
||||||
ByteBuf payload = in.readSlice(payloadLength);
|
ByteBuf payload = in.readSlice(payloadLength);
|
||||||
|
|
||||||
// Read the payload and fire the frame event to the observer.
|
// Read the payload and fire the frame event to the listener.
|
||||||
switch (frameType) {
|
switch (frameType) {
|
||||||
case DATA:
|
case DATA:
|
||||||
readDataFrame(ctx, payload, observer);
|
readDataFrame(ctx, payload, listener);
|
||||||
break;
|
break;
|
||||||
case HEADERS:
|
case HEADERS:
|
||||||
readHeadersFrame(ctx, payload, observer);
|
readHeadersFrame(ctx, payload, listener);
|
||||||
break;
|
break;
|
||||||
case PRIORITY:
|
case PRIORITY:
|
||||||
readPriorityFrame(ctx, payload, observer);
|
readPriorityFrame(ctx, payload, listener);
|
||||||
break;
|
break;
|
||||||
case RST_STREAM:
|
case RST_STREAM:
|
||||||
readRstStreamFrame(ctx, payload, observer);
|
readRstStreamFrame(ctx, payload, listener);
|
||||||
break;
|
break;
|
||||||
case SETTINGS:
|
case SETTINGS:
|
||||||
readSettingsFrame(ctx, payload, observer);
|
readSettingsFrame(ctx, payload, listener);
|
||||||
break;
|
break;
|
||||||
case PUSH_PROMISE:
|
case PUSH_PROMISE:
|
||||||
readPushPromiseFrame(ctx, payload, observer);
|
readPushPromiseFrame(ctx, payload, listener);
|
||||||
break;
|
break;
|
||||||
case PING:
|
case PING:
|
||||||
readPingFrame(ctx, payload, observer);
|
readPingFrame(ctx, payload, listener);
|
||||||
break;
|
break;
|
||||||
case GO_AWAY:
|
case GO_AWAY:
|
||||||
readGoAwayFrame(ctx, payload, observer);
|
readGoAwayFrame(ctx, payload, listener);
|
||||||
break;
|
break;
|
||||||
case WINDOW_UPDATE:
|
case WINDOW_UPDATE:
|
||||||
readWindowUpdateFrame(ctx, payload, observer);
|
readWindowUpdateFrame(ctx, payload, listener);
|
||||||
break;
|
break;
|
||||||
case CONTINUATION:
|
case CONTINUATION:
|
||||||
readContinuationFrame(payload, observer);
|
readContinuationFrame(payload, listener);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
readUnknownFrame(ctx, payload, observer);
|
readUnknownFrame(ctx, payload, listener);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,7 +368,7 @@ public class DefaultHttp2FrameReader implements Http2FrameReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void readDataFrame(ChannelHandlerContext ctx, ByteBuf payload,
|
private void readDataFrame(ChannelHandlerContext ctx, ByteBuf payload,
|
||||||
Http2FrameObserver observer) throws Http2Exception {
|
Http2FrameListener listener) throws Http2Exception {
|
||||||
short padding = readPadding(payload);
|
short padding = readPadding(payload);
|
||||||
|
|
||||||
// Determine how much data there is to read by removing the trailing
|
// Determine how much data there is to read by removing the trailing
|
||||||
@ -379,12 +379,12 @@ public class DefaultHttp2FrameReader implements Http2FrameReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ByteBuf data = payload.readSlice(dataLength);
|
ByteBuf data = payload.readSlice(dataLength);
|
||||||
observer.onDataRead(ctx, streamId, data, padding, flags.endOfStream());
|
listener.onDataRead(ctx, streamId, data, padding, flags.endOfStream());
|
||||||
payload.skipBytes(payload.readableBytes());
|
payload.skipBytes(payload.readableBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readHeadersFrame(final ChannelHandlerContext ctx, ByteBuf payload,
|
private void readHeadersFrame(final ChannelHandlerContext ctx, ByteBuf payload,
|
||||||
Http2FrameObserver observer) throws Http2Exception {
|
Http2FrameListener listener) throws Http2Exception {
|
||||||
final int headersStreamId = streamId;
|
final int headersStreamId = streamId;
|
||||||
final Http2Flags headersFlags = flags;
|
final Http2Flags headersFlags = flags;
|
||||||
final int padding = readPadding(payload);
|
final int padding = readPadding(payload);
|
||||||
@ -398,7 +398,7 @@ public class DefaultHttp2FrameReader implements Http2FrameReader {
|
|||||||
final short weight = (short) (payload.readUnsignedByte() + 1);
|
final short weight = (short) (payload.readUnsignedByte() + 1);
|
||||||
final ByteBuf fragment = payload.readSlice(payload.readableBytes() - padding);
|
final ByteBuf fragment = payload.readSlice(payload.readableBytes() - padding);
|
||||||
|
|
||||||
// Create a handler that invokes the observer when the header block is complete.
|
// Create a handler that invokes the listener when the header block is complete.
|
||||||
headersContinuation = new HeadersContinuation() {
|
headersContinuation = new HeadersContinuation() {
|
||||||
@Override
|
@Override
|
||||||
public int getStreamId() {
|
public int getStreamId() {
|
||||||
@ -407,24 +407,24 @@ public class DefaultHttp2FrameReader implements Http2FrameReader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processFragment(boolean endOfHeaders, ByteBuf fragment,
|
public void processFragment(boolean endOfHeaders, ByteBuf fragment,
|
||||||
Http2FrameObserver observer) throws Http2Exception {
|
Http2FrameListener listener) throws Http2Exception {
|
||||||
builder().addFragment(fragment, ctx.alloc(), endOfHeaders);
|
builder().addFragment(fragment, ctx.alloc(), endOfHeaders);
|
||||||
if (endOfHeaders) {
|
if (endOfHeaders) {
|
||||||
Http2Headers headers = builder().buildHeaders();
|
Http2Headers headers = builder().buildHeaders();
|
||||||
observer.onHeadersRead(ctx, headersStreamId, headers, streamDependency,
|
listener.onHeadersRead(ctx, headersStreamId, headers, streamDependency,
|
||||||
weight, exclusive, padding, headersFlags.endOfStream());
|
weight, exclusive, padding, headersFlags.endOfStream());
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Process the initial fragment, invoking the observer's callback if end of headers.
|
// Process the initial fragment, invoking the listener's callback if end of headers.
|
||||||
headersContinuation.processFragment(flags.endOfHeaders(), fragment, observer);
|
headersContinuation.processFragment(flags.endOfHeaders(), fragment, listener);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The priority fields are not present in the frame. Prepare a continuation that invokes
|
// The priority fields are not present in the frame. Prepare a continuation that invokes
|
||||||
// the observer callback without priority information.
|
// the listener callback without priority information.
|
||||||
headersContinuation = new HeadersContinuation() {
|
headersContinuation = new HeadersContinuation() {
|
||||||
@Override
|
@Override
|
||||||
public int getStreamId() {
|
public int getStreamId() {
|
||||||
@ -433,41 +433,41 @@ public class DefaultHttp2FrameReader implements Http2FrameReader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processFragment(boolean endOfHeaders, ByteBuf fragment,
|
public void processFragment(boolean endOfHeaders, ByteBuf fragment,
|
||||||
Http2FrameObserver observer) throws Http2Exception {
|
Http2FrameListener listener) throws Http2Exception {
|
||||||
builder().addFragment(fragment, ctx.alloc(), endOfHeaders);
|
builder().addFragment(fragment, ctx.alloc(), endOfHeaders);
|
||||||
if (endOfHeaders) {
|
if (endOfHeaders) {
|
||||||
Http2Headers headers = builder().buildHeaders();
|
Http2Headers headers = builder().buildHeaders();
|
||||||
observer.onHeadersRead(ctx, headersStreamId, headers, padding,
|
listener.onHeadersRead(ctx, headersStreamId, headers, padding,
|
||||||
headersFlags.endOfStream());
|
headersFlags.endOfStream());
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Process the initial fragment, invoking the observer's callback if end of headers.
|
// Process the initial fragment, invoking the listener's callback if end of headers.
|
||||||
final ByteBuf fragment = payload.readSlice(payload.readableBytes() - padding);
|
final ByteBuf fragment = payload.readSlice(payload.readableBytes() - padding);
|
||||||
headersContinuation.processFragment(flags.endOfHeaders(), fragment, observer);
|
headersContinuation.processFragment(flags.endOfHeaders(), fragment, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readPriorityFrame(ChannelHandlerContext ctx, ByteBuf payload,
|
private void readPriorityFrame(ChannelHandlerContext ctx, ByteBuf payload,
|
||||||
Http2FrameObserver observer) throws Http2Exception {
|
Http2FrameListener listener) throws Http2Exception {
|
||||||
long word1 = payload.readUnsignedInt();
|
long word1 = payload.readUnsignedInt();
|
||||||
boolean exclusive = (word1 & 0x80000000L) > 0;
|
boolean exclusive = (word1 & 0x80000000L) > 0;
|
||||||
int streamDependency = (int) (word1 & 0x7FFFFFFFL);
|
int streamDependency = (int) (word1 & 0x7FFFFFFFL);
|
||||||
short weight = (short) (payload.readUnsignedByte() + 1);
|
short weight = (short) (payload.readUnsignedByte() + 1);
|
||||||
observer.onPriorityRead(ctx, streamId, streamDependency, weight, exclusive);
|
listener.onPriorityRead(ctx, streamId, streamDependency, weight, exclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readRstStreamFrame(ChannelHandlerContext ctx, ByteBuf payload,
|
private void readRstStreamFrame(ChannelHandlerContext ctx, ByteBuf payload,
|
||||||
Http2FrameObserver observer) throws Http2Exception {
|
Http2FrameListener listener) throws Http2Exception {
|
||||||
long errorCode = payload.readUnsignedInt();
|
long errorCode = payload.readUnsignedInt();
|
||||||
observer.onRstStreamRead(ctx, streamId, errorCode);
|
listener.onRstStreamRead(ctx, streamId, errorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readSettingsFrame(ChannelHandlerContext ctx, ByteBuf payload,
|
private void readSettingsFrame(ChannelHandlerContext ctx, ByteBuf payload,
|
||||||
Http2FrameObserver observer) throws Http2Exception {
|
Http2FrameListener listener) throws Http2Exception {
|
||||||
if (flags.ack()) {
|
if (flags.ack()) {
|
||||||
observer.onSettingsAckRead(ctx);
|
listener.onSettingsAckRead(ctx);
|
||||||
} else {
|
} else {
|
||||||
int numSettings = payloadLength / SETTING_ENTRY_LENGTH;
|
int numSettings = payloadLength / SETTING_ENTRY_LENGTH;
|
||||||
Http2Settings settings = new Http2Settings();
|
Http2Settings settings = new Http2Settings();
|
||||||
@ -484,19 +484,19 @@ public class DefaultHttp2FrameReader implements Http2FrameReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
observer.onSettingsRead(ctx, settings);
|
listener.onSettingsRead(ctx, settings);
|
||||||
// Provide an interface for non-observers to capture settings
|
// Provide an interface for non-listeners to capture settings
|
||||||
ctx.fireChannelRead(settings);
|
ctx.fireChannelRead(settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readPushPromiseFrame(final ChannelHandlerContext ctx, ByteBuf payload,
|
private void readPushPromiseFrame(final ChannelHandlerContext ctx, ByteBuf payload,
|
||||||
Http2FrameObserver observer) throws Http2Exception {
|
Http2FrameListener listener) throws Http2Exception {
|
||||||
final int pushPromiseStreamId = streamId;
|
final int pushPromiseStreamId = streamId;
|
||||||
final int padding = readPadding(payload);
|
final int padding = readPadding(payload);
|
||||||
final int promisedStreamId = readUnsignedInt(payload);
|
final int promisedStreamId = readUnsignedInt(payload);
|
||||||
|
|
||||||
// Create a handler that invokes the observer when the header block is complete.
|
// Create a handler that invokes the listener when the header block is complete.
|
||||||
headersContinuation = new HeadersContinuation() {
|
headersContinuation = new HeadersContinuation() {
|
||||||
@Override
|
@Override
|
||||||
public int getStreamId() {
|
public int getStreamId() {
|
||||||
@ -505,58 +505,58 @@ public class DefaultHttp2FrameReader implements Http2FrameReader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processFragment(boolean endOfHeaders, ByteBuf fragment,
|
public void processFragment(boolean endOfHeaders, ByteBuf fragment,
|
||||||
Http2FrameObserver observer) throws Http2Exception {
|
Http2FrameListener listener) throws Http2Exception {
|
||||||
builder().addFragment(fragment, ctx.alloc(), endOfHeaders);
|
builder().addFragment(fragment, ctx.alloc(), endOfHeaders);
|
||||||
if (endOfHeaders) {
|
if (endOfHeaders) {
|
||||||
Http2Headers headers = builder().buildHeaders();
|
Http2Headers headers = builder().buildHeaders();
|
||||||
observer.onPushPromiseRead(ctx, pushPromiseStreamId, promisedStreamId, headers,
|
listener.onPushPromiseRead(ctx, pushPromiseStreamId, promisedStreamId, headers,
|
||||||
padding);
|
padding);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Process the initial fragment, invoking the observer's callback if end of headers.
|
// Process the initial fragment, invoking the listener's callback if end of headers.
|
||||||
final ByteBuf fragment = payload.readSlice(payload.readableBytes() - padding);
|
final ByteBuf fragment = payload.readSlice(payload.readableBytes() - padding);
|
||||||
headersContinuation.processFragment(flags.endOfHeaders(), fragment, observer);
|
headersContinuation.processFragment(flags.endOfHeaders(), fragment, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readPingFrame(ChannelHandlerContext ctx, ByteBuf payload,
|
private void readPingFrame(ChannelHandlerContext ctx, ByteBuf payload,
|
||||||
Http2FrameObserver observer) throws Http2Exception {
|
Http2FrameListener listener) throws Http2Exception {
|
||||||
ByteBuf data = payload.readSlice(payload.readableBytes());
|
ByteBuf data = payload.readSlice(payload.readableBytes());
|
||||||
if (flags.ack()) {
|
if (flags.ack()) {
|
||||||
observer.onPingAckRead(ctx, data);
|
listener.onPingAckRead(ctx, data);
|
||||||
} else {
|
} else {
|
||||||
observer.onPingRead(ctx, data);
|
listener.onPingRead(ctx, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void readGoAwayFrame(ChannelHandlerContext ctx, ByteBuf payload,
|
private static void readGoAwayFrame(ChannelHandlerContext ctx, ByteBuf payload,
|
||||||
Http2FrameObserver observer) throws Http2Exception {
|
Http2FrameListener listener) throws Http2Exception {
|
||||||
int lastStreamId = readUnsignedInt(payload);
|
int lastStreamId = readUnsignedInt(payload);
|
||||||
long errorCode = payload.readUnsignedInt();
|
long errorCode = payload.readUnsignedInt();
|
||||||
ByteBuf debugData = payload.readSlice(payload.readableBytes());
|
ByteBuf debugData = payload.readSlice(payload.readableBytes());
|
||||||
observer.onGoAwayRead(ctx, lastStreamId, errorCode, debugData);
|
listener.onGoAwayRead(ctx, lastStreamId, errorCode, debugData);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readWindowUpdateFrame(ChannelHandlerContext ctx, ByteBuf payload,
|
private void readWindowUpdateFrame(ChannelHandlerContext ctx, ByteBuf payload,
|
||||||
Http2FrameObserver observer) throws Http2Exception {
|
Http2FrameListener listener) throws Http2Exception {
|
||||||
int windowSizeIncrement = readUnsignedInt(payload);
|
int windowSizeIncrement = readUnsignedInt(payload);
|
||||||
observer.onWindowUpdateRead(ctx, streamId, windowSizeIncrement);
|
listener.onWindowUpdateRead(ctx, streamId, windowSizeIncrement);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readContinuationFrame(ByteBuf payload, Http2FrameObserver observer)
|
private void readContinuationFrame(ByteBuf payload, Http2FrameListener listener)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
// Process the initial fragment, invoking the observer's callback if end of headers.
|
// Process the initial fragment, invoking the listener's callback if end of headers.
|
||||||
final ByteBuf continuationFragment = payload.readSlice(payload.readableBytes());
|
final ByteBuf continuationFragment = payload.readSlice(payload.readableBytes());
|
||||||
headersContinuation.processFragment(flags.endOfHeaders(), continuationFragment,
|
headersContinuation.processFragment(flags.endOfHeaders(), continuationFragment,
|
||||||
observer);
|
listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readUnknownFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameObserver observer)
|
private void readUnknownFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
payload = payload.readSlice(payload.readableBytes());
|
payload = payload.readSlice(payload.readableBytes());
|
||||||
observer.onUnknownFrame(ctx, frameType, streamId, flags, payload);
|
listener.onUnknownFrame(ctx, frameType, streamId, flags, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -572,7 +572,7 @@ public class DefaultHttp2FrameReader implements Http2FrameReader {
|
|||||||
/**
|
/**
|
||||||
* Base class for processing of HEADERS and PUSH_PROMISE header blocks that potentially span
|
* Base class for processing of HEADERS and PUSH_PROMISE header blocks that potentially span
|
||||||
* multiple frames. The implementation of this interface will perform the final callback to the
|
* multiple frames. The implementation of this interface will perform the final callback to the
|
||||||
* {@link Http2FrameObserver} once the end of headers is reached.
|
* {@link Http2FrameListener} once the end of headers is reached.
|
||||||
*/
|
*/
|
||||||
private abstract class HeadersContinuation {
|
private abstract class HeadersContinuation {
|
||||||
private final HeadersBuilder builder = new HeadersBuilder();
|
private final HeadersBuilder builder = new HeadersBuilder();
|
||||||
@ -587,10 +587,10 @@ public class DefaultHttp2FrameReader implements Http2FrameReader {
|
|||||||
*
|
*
|
||||||
* @param endOfHeaders whether the fragment is the last in the header block.
|
* @param endOfHeaders whether the fragment is the last in the header block.
|
||||||
* @param fragment the fragment of the header block to be added.
|
* @param fragment the fragment of the header block to be added.
|
||||||
* @param observer the observer to be notified if the header block is completed.
|
* @param listener the listener to be notified if the header block is completed.
|
||||||
*/
|
*/
|
||||||
abstract void processFragment(boolean endOfHeaders, ByteBuf fragment,
|
abstract void processFragment(boolean endOfHeaders, ByteBuf fragment,
|
||||||
Http2FrameObserver observer) throws Http2Exception;
|
Http2FrameListener listener) throws Http2Exception;
|
||||||
|
|
||||||
final HeadersBuilder builder() {
|
final HeadersBuilder builder() {
|
||||||
return builder;
|
return builder;
|
||||||
|
@ -25,30 +25,30 @@ import io.netty.channel.ChannelPromise;
|
|||||||
* models, rather than having to subclass it directly.
|
* models, rather than having to subclass it directly.
|
||||||
* <p>
|
* <p>
|
||||||
* Exposes all {@code writeXXX} methods as public and delegates all frame read events to a provided
|
* Exposes all {@code writeXXX} methods as public and delegates all frame read events to a provided
|
||||||
* {@link Http2FrameObserver}.
|
* {@link Http2FrameListener}.
|
||||||
* <p>
|
* <p>
|
||||||
* The {@link #channelActive} and {@link #handlerAdded} should called when appropriate to ensure
|
* The {@link #channelActive} and {@link #handlerAdded} should called when appropriate to ensure
|
||||||
* that the initial SETTINGS frame is sent to the remote endpoint.
|
* that the initial SETTINGS frame is sent to the remote endpoint.
|
||||||
*/
|
*/
|
||||||
public class DelegatingHttp2ConnectionHandler extends AbstractHttp2ConnectionHandler {
|
public class DelegatingHttp2ConnectionHandler extends AbstractHttp2ConnectionHandler {
|
||||||
private final Http2FrameObserver observer;
|
private final Http2FrameListener listener;
|
||||||
|
|
||||||
public DelegatingHttp2ConnectionHandler(boolean server, Http2FrameObserver observer) {
|
public DelegatingHttp2ConnectionHandler(boolean server, Http2FrameListener listener) {
|
||||||
super(server);
|
super(server);
|
||||||
this.observer = observer;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DelegatingHttp2ConnectionHandler(Http2Connection connection,
|
public DelegatingHttp2ConnectionHandler(Http2Connection connection,
|
||||||
Http2FrameReader frameReader, Http2FrameWriter frameWriter,
|
Http2FrameReader frameReader, Http2FrameWriter frameWriter,
|
||||||
Http2InboundFlowController inboundFlow, Http2OutboundFlowController outboundFlow,
|
Http2InboundFlowController inboundFlow, Http2OutboundFlowController outboundFlow,
|
||||||
Http2FrameObserver observer) {
|
Http2FrameListener listener) {
|
||||||
super(connection, frameReader, frameWriter, inboundFlow, outboundFlow);
|
super(connection, frameReader, frameWriter, inboundFlow, outboundFlow);
|
||||||
this.observer = observer;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DelegatingHttp2ConnectionHandler(Http2Connection connection, Http2FrameObserver observer) {
|
public DelegatingHttp2ConnectionHandler(Http2Connection connection, Http2FrameListener listener) {
|
||||||
super(connection);
|
super(connection);
|
||||||
this.observer = observer;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -103,70 +103,70 @@ public class DelegatingHttp2ConnectionHandler extends AbstractHttp2ConnectionHan
|
|||||||
@Override
|
@Override
|
||||||
public void onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding,
|
public void onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding,
|
||||||
boolean endOfStream) throws Http2Exception {
|
boolean endOfStream) throws Http2Exception {
|
||||||
observer.onDataRead(ctx, streamId, data, padding, endOfStream);
|
listener.onDataRead(ctx, streamId, data, padding, endOfStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers,
|
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers,
|
||||||
int streamDependency, short weight, boolean exclusive, int padding, boolean endStream)
|
int streamDependency, short weight, boolean exclusive, int padding, boolean endStream)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
observer.onHeadersRead(ctx, streamId, headers, streamDependency, weight, exclusive,
|
listener.onHeadersRead(ctx, streamId, headers, streamDependency, weight, exclusive,
|
||||||
padding, endStream);
|
padding, endStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPriorityRead(ChannelHandlerContext ctx, int streamId, int streamDependency,
|
public void onPriorityRead(ChannelHandlerContext ctx, int streamId, int streamDependency,
|
||||||
short weight, boolean exclusive) throws Http2Exception {
|
short weight, boolean exclusive) throws Http2Exception {
|
||||||
observer.onPriorityRead(ctx, streamId, streamDependency, weight, exclusive);
|
listener.onPriorityRead(ctx, streamId, streamDependency, weight, exclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode)
|
public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
observer.onRstStreamRead(ctx, streamId, errorCode);
|
listener.onRstStreamRead(ctx, streamId, errorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSettingsAckRead(ChannelHandlerContext ctx) throws Http2Exception {
|
public void onSettingsAckRead(ChannelHandlerContext ctx) throws Http2Exception {
|
||||||
observer.onSettingsAckRead(ctx);
|
listener.onSettingsAckRead(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) throws Http2Exception {
|
public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) throws Http2Exception {
|
||||||
observer.onSettingsRead(ctx, settings);
|
listener.onSettingsRead(ctx, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPingRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
public void onPingRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
||||||
observer.onPingRead(ctx, data);
|
listener.onPingRead(ctx, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPingAckRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
public void onPingAckRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
||||||
observer.onPingAckRead(ctx, data);
|
listener.onPingAckRead(ctx, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promisedStreamId,
|
public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promisedStreamId,
|
||||||
Http2Headers headers, int padding) throws Http2Exception {
|
Http2Headers headers, int padding) throws Http2Exception {
|
||||||
observer.onPushPromiseRead(ctx, streamId, promisedStreamId, headers, padding);
|
listener.onPushPromiseRead(ctx, streamId, promisedStreamId, headers, padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGoAwayRead(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData)
|
public void onGoAwayRead(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
observer.onGoAwayRead(ctx, lastStreamId, errorCode, debugData);
|
listener.onGoAwayRead(ctx, lastStreamId, errorCode, debugData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWindowUpdateRead(ChannelHandlerContext ctx, int streamId, int windowSizeIncrement)
|
public void onWindowUpdateRead(ChannelHandlerContext ctx, int streamId, int windowSizeIncrement)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
observer.onWindowUpdateRead(ctx, streamId, windowSizeIncrement);
|
listener.onWindowUpdateRead(ctx, streamId, windowSizeIncrement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUnknownFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags,
|
public void onUnknownFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags,
|
||||||
ByteBuf payload) {
|
ByteBuf payload) {
|
||||||
observer.onUnknownFrame(ctx, frameType, streamId, flags, payload);
|
listener.onUnknownFrame(ctx, frameType, streamId, flags, payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,18 +31,18 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class DelegatingHttp2HttpConnectionHandler extends DelegatingHttp2ConnectionHandler {
|
public class DelegatingHttp2HttpConnectionHandler extends DelegatingHttp2ConnectionHandler {
|
||||||
|
|
||||||
public DelegatingHttp2HttpConnectionHandler(boolean server, Http2FrameObserver observer) {
|
public DelegatingHttp2HttpConnectionHandler(boolean server, Http2FrameListener listener) {
|
||||||
super(server, observer);
|
super(server, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DelegatingHttp2HttpConnectionHandler(Http2Connection connection, Http2FrameReader frameReader,
|
public DelegatingHttp2HttpConnectionHandler(Http2Connection connection, Http2FrameReader frameReader,
|
||||||
Http2FrameWriter frameWriter, Http2InboundFlowController inboundFlow,
|
Http2FrameWriter frameWriter, Http2InboundFlowController inboundFlow,
|
||||||
Http2OutboundFlowController outboundFlow, Http2FrameObserver observer) {
|
Http2OutboundFlowController outboundFlow, Http2FrameListener listener) {
|
||||||
super(connection, frameReader, frameWriter, inboundFlow, outboundFlow, observer);
|
super(connection, frameReader, frameWriter, inboundFlow, outboundFlow, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DelegatingHttp2HttpConnectionHandler(Http2Connection connection, Http2FrameObserver observer) {
|
public DelegatingHttp2HttpConnectionHandler(Http2Connection connection, Http2FrameListener listener) {
|
||||||
super(connection, observer);
|
super(connection, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,16 +18,16 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An observer of HTTP/2 {@code DATA} frames.
|
* An listener of HTTP/2 {@code DATA} frames.
|
||||||
*/
|
*/
|
||||||
public interface Http2DataObserver {
|
public interface Http2DataListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles an inbound {@code DATA} frame.
|
* Handles an inbound {@code DATA} frame.
|
||||||
*
|
*
|
||||||
* @param ctx the context from the handler where the frame was read.
|
* @param ctx the context from the handler where the frame was read.
|
||||||
* @param streamId the subject stream for the frame.
|
* @param streamId the subject stream for the frame.
|
||||||
* @param data payload buffer for the frame. If this buffer needs to be retained by the observer
|
* @param data payload buffer for the frame. If this buffer needs to be retained by the listener
|
||||||
* they must make a copy.
|
* they must make a copy.
|
||||||
* @param padding the number of padding bytes found at the end of the frame.
|
* @param padding the number of padding bytes found at the end of the frame.
|
||||||
* @param endOfStream Indicates whether this is the last frame to be sent from the remote
|
* @param endOfStream Indicates whether this is the last frame to be sent from the remote
|
@ -18,10 +18,10 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class brings {@link Http2Connection.Listener} and {@link Http2FrameObserver} together to provide
|
* This class brings {@link Http2Connection.Listener} and {@link Http2FrameListener} together to provide
|
||||||
* NOOP implementation so inheriting classes can selectively choose which methods to override.
|
* NOOP implementation so inheriting classes can selectively choose which methods to override.
|
||||||
*/
|
*/
|
||||||
public class Http2EventAdapter implements Http2Connection.Listener, Http2FrameObserver {
|
public class Http2EventAdapter implements Http2Connection.Listener, Http2FrameListener {
|
||||||
@Override
|
@Override
|
||||||
public void onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding, boolean endOfStream)
|
public void onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding, boolean endOfStream)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
|
@ -18,9 +18,9 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience class that provides no-op implementations for all methods of {@link Http2FrameObserver}.
|
* Convenience class that provides no-op implementations for all methods of {@link Http2FrameListener}.
|
||||||
*/
|
*/
|
||||||
public class Http2FrameAdapter implements Http2FrameObserver {
|
public class Http2FrameAdapter implements Http2FrameListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding,
|
public void onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding,
|
||||||
|
@ -19,9 +19,9 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An observer of HTTP/2 frames.
|
* An listener of HTTP/2 frames.
|
||||||
*/
|
*/
|
||||||
public interface Http2FrameObserver extends Http2DataObserver {
|
public interface Http2FrameListener extends Http2DataListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles an inbound HEADERS frame.
|
* Handles an inbound HEADERS frame.
|
||||||
@ -117,7 +117,7 @@ public interface Http2FrameObserver extends Http2DataObserver {
|
|||||||
* Handles an inbound PING frame.
|
* Handles an inbound PING frame.
|
||||||
*
|
*
|
||||||
* @param ctx the context from the handler where the frame was read.
|
* @param ctx the context from the handler where the frame was read.
|
||||||
* @param data the payload of the frame. If this buffer needs to be retained by the observer
|
* @param data the payload of the frame. If this buffer needs to be retained by the listener
|
||||||
* they must make a copy.
|
* they must make a copy.
|
||||||
*/
|
*/
|
||||||
void onPingRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception;
|
void onPingRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception;
|
||||||
@ -126,7 +126,7 @@ public interface Http2FrameObserver extends Http2DataObserver {
|
|||||||
* Handles an inbound PING acknowledgment.
|
* Handles an inbound PING acknowledgment.
|
||||||
*
|
*
|
||||||
* @param ctx the context from the handler where the frame was read.
|
* @param ctx the context from the handler where the frame was read.
|
||||||
* @param data the payload of the frame. If this buffer needs to be retained by the observer
|
* @param data the payload of the frame. If this buffer needs to be retained by the listener
|
||||||
* they must make a copy.
|
* they must make a copy.
|
||||||
*/
|
*/
|
||||||
void onPingAckRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception;
|
void onPingAckRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception;
|
||||||
@ -162,7 +162,7 @@ public interface Http2FrameObserver extends Http2DataObserver {
|
|||||||
* @param lastStreamId the last known stream of the remote endpoint.
|
* @param lastStreamId the last known stream of the remote endpoint.
|
||||||
* @param errorCode the error code, if abnormal closure.
|
* @param errorCode the error code, if abnormal closure.
|
||||||
* @param debugData application-defined debug data. If this buffer needs to be retained by the
|
* @param debugData application-defined debug data. If this buffer needs to be retained by the
|
||||||
* observer they must make a copy.
|
* listener they must make a copy.
|
||||||
*/
|
*/
|
||||||
void onGoAwayRead(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData)
|
void onGoAwayRead(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData)
|
||||||
throws Http2Exception;
|
throws Http2Exception;
|
@ -22,15 +22,15 @@ import java.io.Closeable;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads HTTP/2 frames from an input {@link ByteBuf} and notifies the specified
|
* Reads HTTP/2 frames from an input {@link ByteBuf} and notifies the specified
|
||||||
* {@link Http2FrameObserver} when frames are complete.
|
* {@link Http2FrameListener} when frames are complete.
|
||||||
*/
|
*/
|
||||||
public interface Http2FrameReader extends Closeable {
|
public interface Http2FrameReader extends Closeable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to read the next frame from the input buffer. If enough data is available to fully
|
* Attempts to read the next frame from the input buffer. If enough data is available to fully
|
||||||
* read the frame, notifies the observer of the read frame.
|
* read the frame, notifies the listener of the read frame.
|
||||||
*/
|
*/
|
||||||
void readFrame(ChannelHandlerContext ctx, ByteBuf input, Http2FrameObserver observer)
|
void readFrame(ChannelHandlerContext ctx, ByteBuf input, Http2FrameListener listener)
|
||||||
throws Http2Exception;
|
throws Http2Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +18,7 @@ package io.netty.handler.codec.http2;
|
|||||||
/**
|
/**
|
||||||
* Controls the inbound flow of data frames from the remote endpoint.
|
* Controls the inbound flow of data frames from the remote endpoint.
|
||||||
*/
|
*/
|
||||||
public interface Http2InboundFlowController extends Http2DataObserver {
|
public interface Http2InboundFlowController extends Http2DataListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the initial inbound flow control window size and updates all stream window sizes by the
|
* Sets the initial inbound flow control window size and updates all stream window sizes by the
|
||||||
|
@ -21,7 +21,7 @@ import io.netty.channel.ChannelHandlerContext;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Decorator around a {@link Http2FrameReader} that logs all inbound frames before calling
|
* Decorator around a {@link Http2FrameReader} that logs all inbound frames before calling
|
||||||
* back the observer.
|
* back the listener.
|
||||||
*/
|
*/
|
||||||
public class Http2InboundFrameLogger implements Http2FrameReader {
|
public class Http2InboundFrameLogger implements Http2FrameReader {
|
||||||
|
|
||||||
@ -40,16 +40,16 @@ public class Http2InboundFrameLogger implements Http2FrameReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFrame(ChannelHandlerContext ctx, ByteBuf input, final Http2FrameObserver observer)
|
public void readFrame(ChannelHandlerContext ctx, ByteBuf input, final Http2FrameListener listener)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
reader.readFrame(ctx, input, new Http2FrameObserver() {
|
reader.readFrame(ctx, input, new Http2FrameListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data,
|
public void onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data,
|
||||||
int padding, boolean endOfStream)
|
int padding, boolean endOfStream)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
logger.logData(INBOUND, streamId, data, padding, endOfStream);
|
logger.logData(INBOUND, streamId, data, padding, endOfStream);
|
||||||
observer.onDataRead(ctx, streamId, data, padding, endOfStream);
|
listener.onDataRead(ctx, streamId, data, padding, endOfStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -57,7 +57,7 @@ public class Http2InboundFrameLogger implements Http2FrameReader {
|
|||||||
Http2Headers headers, int padding, boolean endStream)
|
Http2Headers headers, int padding, boolean endStream)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
logger.logHeaders(INBOUND, streamId, headers, padding, endStream);
|
logger.logHeaders(INBOUND, streamId, headers, padding, endStream);
|
||||||
observer.onHeadersRead(ctx, streamId, headers, padding, endStream);
|
listener.onHeadersRead(ctx, streamId, headers, padding, endStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -66,7 +66,7 @@ public class Http2InboundFrameLogger implements Http2FrameReader {
|
|||||||
int padding, boolean endStream) throws Http2Exception {
|
int padding, boolean endStream) throws Http2Exception {
|
||||||
logger.logHeaders(INBOUND, streamId, headers, streamDependency, weight, exclusive,
|
logger.logHeaders(INBOUND, streamId, headers, streamDependency, weight, exclusive,
|
||||||
padding, endStream);
|
padding, endStream);
|
||||||
observer.onHeadersRead(ctx, streamId, headers, streamDependency, weight, exclusive,
|
listener.onHeadersRead(ctx, streamId, headers, streamDependency, weight, exclusive,
|
||||||
padding, endStream);
|
padding, endStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,67 +74,67 @@ public class Http2InboundFrameLogger implements Http2FrameReader {
|
|||||||
public void onPriorityRead(ChannelHandlerContext ctx, int streamId,
|
public void onPriorityRead(ChannelHandlerContext ctx, int streamId,
|
||||||
int streamDependency, short weight, boolean exclusive) throws Http2Exception {
|
int streamDependency, short weight, boolean exclusive) throws Http2Exception {
|
||||||
logger.logPriority(INBOUND, streamId, streamDependency, weight, exclusive);
|
logger.logPriority(INBOUND, streamId, streamDependency, weight, exclusive);
|
||||||
observer.onPriorityRead(ctx, streamId, streamDependency, weight, exclusive);
|
listener.onPriorityRead(ctx, streamId, streamDependency, weight, exclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode)
|
public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
logger.logRstStream(INBOUND, streamId, errorCode);
|
logger.logRstStream(INBOUND, streamId, errorCode);
|
||||||
observer.onRstStreamRead(ctx, streamId, errorCode);
|
listener.onRstStreamRead(ctx, streamId, errorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSettingsAckRead(ChannelHandlerContext ctx) throws Http2Exception {
|
public void onSettingsAckRead(ChannelHandlerContext ctx) throws Http2Exception {
|
||||||
logger.logSettingsAck(INBOUND);
|
logger.logSettingsAck(INBOUND);
|
||||||
observer.onSettingsAckRead(ctx);
|
listener.onSettingsAckRead(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings)
|
public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
logger.logSettings(INBOUND, settings);
|
logger.logSettings(INBOUND, settings);
|
||||||
observer.onSettingsRead(ctx, settings);
|
listener.onSettingsRead(ctx, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPingRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
public void onPingRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
||||||
logger.logPing(INBOUND, data);
|
logger.logPing(INBOUND, data);
|
||||||
observer.onPingRead(ctx, data);
|
listener.onPingRead(ctx, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPingAckRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
public void onPingAckRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
||||||
logger.logPingAck(INBOUND, data);
|
logger.logPingAck(INBOUND, data);
|
||||||
observer.onPingAckRead(ctx, data);
|
listener.onPingAckRead(ctx, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId,
|
public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId,
|
||||||
int promisedStreamId, Http2Headers headers, int padding) throws Http2Exception {
|
int promisedStreamId, Http2Headers headers, int padding) throws Http2Exception {
|
||||||
logger.logPushPromise(INBOUND, streamId, promisedStreamId, headers, padding);
|
logger.logPushPromise(INBOUND, streamId, promisedStreamId, headers, padding);
|
||||||
observer.onPushPromiseRead(ctx, streamId, promisedStreamId, headers, padding);
|
listener.onPushPromiseRead(ctx, streamId, promisedStreamId, headers, padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGoAwayRead(ChannelHandlerContext ctx, int lastStreamId, long errorCode,
|
public void onGoAwayRead(ChannelHandlerContext ctx, int lastStreamId, long errorCode,
|
||||||
ByteBuf debugData) throws Http2Exception {
|
ByteBuf debugData) throws Http2Exception {
|
||||||
logger.logGoAway(INBOUND, lastStreamId, errorCode, debugData);
|
logger.logGoAway(INBOUND, lastStreamId, errorCode, debugData);
|
||||||
observer.onGoAwayRead(ctx, lastStreamId, errorCode, debugData);
|
listener.onGoAwayRead(ctx, lastStreamId, errorCode, debugData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWindowUpdateRead(ChannelHandlerContext ctx, int streamId, int windowSizeIncrement)
|
public void onWindowUpdateRead(ChannelHandlerContext ctx, int streamId, int windowSizeIncrement)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
logger.logWindowsUpdate(INBOUND, streamId, windowSizeIncrement);
|
logger.logWindowsUpdate(INBOUND, streamId, windowSizeIncrement);
|
||||||
observer.onWindowUpdateRead(ctx, streamId, windowSizeIncrement);
|
listener.onWindowUpdateRead(ctx, streamId, windowSizeIncrement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUnknownFrame(ChannelHandlerContext ctx, byte frameType, int streamId,
|
public void onUnknownFrame(ChannelHandlerContext ctx, byte frameType, int streamId,
|
||||||
Http2Flags flags, ByteBuf payload) {
|
Http2Flags flags, ByteBuf payload) {
|
||||||
logger.logUnknownFrame(INBOUND, frameType, streamId, flags, payload);
|
logger.logUnknownFrame(INBOUND, frameType, streamId, flags, payload);
|
||||||
observer.onUnknownFrame(ctx, frameType, streamId, flags, payload);
|
listener.onUnknownFrame(ctx, frameType, streamId, flags, payload);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
private ChannelHandlerContext ctx;
|
private ChannelHandlerContext ctx;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private Http2FrameObserver observer;
|
private Http2FrameListener listener;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private ChannelPromise promise;
|
private ChannelPromise promise;
|
||||||
@ -70,8 +70,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
writer.writeData(ctx, 1000, data, 0, false, promise);
|
writer.writeData(ctx, 1000, data, 0, false, promise);
|
||||||
|
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onDataRead(eq(ctx), eq(1000), eq(data), eq(0), eq(false));
|
verify(listener).onDataRead(eq(ctx), eq(1000), eq(data), eq(0), eq(false));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,8 +81,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
writer.writeData(ctx, 1000, data.retain().duplicate(), 0, false, promise);
|
writer.writeData(ctx, 1000, data.retain().duplicate(), 0, false, promise);
|
||||||
|
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onDataRead(eq(ctx), eq(1000), eq(data), eq(0), eq(false));
|
verify(listener).onDataRead(eq(ctx), eq(1000), eq(data), eq(0), eq(false));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,8 +92,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
writer.writeData(ctx, 1, data.retain().duplicate(), 0xFF, true, promise);
|
writer.writeData(ctx, 1, data.retain().duplicate(), 0xFF, true, promise);
|
||||||
|
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onDataRead(eq(ctx), eq(1), eq(data), eq(0xFF), eq(true));
|
verify(listener).onDataRead(eq(ctx), eq(1), eq(data), eq(0xFF), eq(true));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,8 +102,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
writer.writePriority(ctx, 1, 2, (short) 255, true, promise);
|
writer.writePriority(ctx, 1, 2, (short) 255, true, promise);
|
||||||
|
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onPriorityRead(eq(ctx), eq(1), eq(2), eq((short) 255), eq(true));
|
verify(listener).onPriorityRead(eq(ctx), eq(1), eq(2), eq((short) 255), eq(true));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,8 +112,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
writer.writeRstStream(ctx, 1, MAX_UNSIGNED_INT, promise);
|
writer.writeRstStream(ctx, 1, MAX_UNSIGNED_INT, promise);
|
||||||
|
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onRstStreamRead(eq(ctx), eq(1), eq(MAX_UNSIGNED_INT));
|
verify(listener).onRstStreamRead(eq(ctx), eq(1), eq(MAX_UNSIGNED_INT));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,8 +122,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
writer.writeSettings(ctx, new Http2Settings(), promise);
|
writer.writeSettings(ctx, new Http2Settings(), promise);
|
||||||
|
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onSettingsRead(eq(ctx), eq(new Http2Settings()));
|
verify(listener).onSettingsRead(eq(ctx), eq(new Http2Settings()));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,8 +138,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
writer.writeSettings(ctx, settings, promise);
|
writer.writeSettings(ctx, settings, promise);
|
||||||
|
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onSettingsRead(eq(ctx), eq(settings));
|
verify(listener).onSettingsRead(eq(ctx), eq(settings));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,8 +148,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
writer.writeSettingsAck(ctx, promise);
|
writer.writeSettingsAck(ctx, promise);
|
||||||
|
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onSettingsAckRead(eq(ctx));
|
verify(listener).onSettingsAckRead(eq(ctx));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,8 +159,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
writer.writePing(ctx, false, data.retain().duplicate(), promise);
|
writer.writePing(ctx, false, data.retain().duplicate(), promise);
|
||||||
|
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onPingRead(eq(ctx), eq(data));
|
verify(listener).onPingRead(eq(ctx), eq(data));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,8 +170,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
writer.writePing(ctx, true, data.retain().duplicate(), promise);
|
writer.writePing(ctx, true, data.retain().duplicate(), promise);
|
||||||
|
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onPingAckRead(eq(ctx), eq(data));
|
verify(listener).onPingAckRead(eq(ctx), eq(data));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,8 +180,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
ByteBuf data = dummyData();
|
ByteBuf data = dummyData();
|
||||||
writer.writeGoAway(ctx, 1, MAX_UNSIGNED_INT, data.retain().duplicate(), promise);
|
writer.writeGoAway(ctx, 1, MAX_UNSIGNED_INT, data.retain().duplicate(), promise);
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onGoAwayRead(eq(ctx), eq(1), eq(MAX_UNSIGNED_INT), eq(data));
|
verify(listener).onGoAwayRead(eq(ctx), eq(1), eq(MAX_UNSIGNED_INT), eq(data));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,8 +189,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
public void windowUpdateShouldRoundtrip() throws Exception {
|
public void windowUpdateShouldRoundtrip() throws Exception {
|
||||||
writer.writeWindowUpdate(ctx, 1, Integer.MAX_VALUE, promise);
|
writer.writeWindowUpdate(ctx, 1, Integer.MAX_VALUE, promise);
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onWindowUpdateRead(eq(ctx), eq(1), eq(Integer.MAX_VALUE));
|
verify(listener).onWindowUpdateRead(eq(ctx), eq(1), eq(Integer.MAX_VALUE));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,8 +199,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
Http2Headers headers = Http2Headers.EMPTY_HEADERS;
|
Http2Headers headers = Http2Headers.EMPTY_HEADERS;
|
||||||
writer.writeHeaders(ctx, 1, headers, 0, true, promise);
|
writer.writeHeaders(ctx, 1, headers, 0, true, promise);
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onHeadersRead(eq(ctx), eq(1), eq(headers), eq(0), eq(true));
|
verify(listener).onHeadersRead(eq(ctx), eq(1), eq(headers), eq(0), eq(true));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,8 +209,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
Http2Headers headers = Http2Headers.EMPTY_HEADERS;
|
Http2Headers headers = Http2Headers.EMPTY_HEADERS;
|
||||||
writer.writeHeaders(ctx, 1, headers, 0xFF, true, promise);
|
writer.writeHeaders(ctx, 1, headers, 0xFF, true, promise);
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onHeadersRead(eq(ctx), eq(1), eq(headers), eq(0xFF), eq(true));
|
verify(listener).onHeadersRead(eq(ctx), eq(1), eq(headers), eq(0xFF), eq(true));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,8 +219,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
Http2Headers headers = dummyHeaders();
|
Http2Headers headers = dummyHeaders();
|
||||||
writer.writeHeaders(ctx, 1, headers, 0, true, promise);
|
writer.writeHeaders(ctx, 1, headers, 0, true, promise);
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onHeadersRead(eq(ctx), eq(1), eq(headers), eq(0), eq(true));
|
verify(listener).onHeadersRead(eq(ctx), eq(1), eq(headers), eq(0), eq(true));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,8 +229,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
Http2Headers headers = dummyHeaders();
|
Http2Headers headers = dummyHeaders();
|
||||||
writer.writeHeaders(ctx, 1, headers, 0xFF, true, promise);
|
writer.writeHeaders(ctx, 1, headers, 0xFF, true, promise);
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onHeadersRead(eq(ctx), eq(1), eq(headers), eq(0xFF), eq(true));
|
verify(listener).onHeadersRead(eq(ctx), eq(1), eq(headers), eq(0xFF), eq(true));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,8 +239,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
Http2Headers headers = dummyHeaders();
|
Http2Headers headers = dummyHeaders();
|
||||||
writer.writeHeaders(ctx, 1, headers, 2, (short) 3, true, 0, true, promise);
|
writer.writeHeaders(ctx, 1, headers, 2, (short) 3, true, 0, true, promise);
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onHeadersRead(eq(ctx), eq(1), eq(headers), eq(2), eq((short) 3), eq(true), eq(0),
|
verify(listener).onHeadersRead(eq(ctx), eq(1), eq(headers), eq(2), eq((short) 3), eq(true), eq(0),
|
||||||
eq(true));
|
eq(true));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
@ -250,8 +250,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
Http2Headers headers = dummyHeaders();
|
Http2Headers headers = dummyHeaders();
|
||||||
writer.writeHeaders(ctx, 1, headers, 2, (short) 3, true, 0xFF, true, promise);
|
writer.writeHeaders(ctx, 1, headers, 2, (short) 3, true, 0xFF, true, promise);
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onHeadersRead(eq(ctx), eq(1), eq(headers), eq(2), eq((short) 3), eq(true), eq(0xFF),
|
verify(listener).onHeadersRead(eq(ctx), eq(1), eq(headers), eq(2), eq((short) 3), eq(true), eq(0xFF),
|
||||||
eq(true));
|
eq(true));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
@ -261,8 +261,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
Http2Headers headers = largeHeaders();
|
Http2Headers headers = largeHeaders();
|
||||||
writer.writeHeaders(ctx, 1, headers, 2, (short) 3, true, 0, true, promise);
|
writer.writeHeaders(ctx, 1, headers, 2, (short) 3, true, 0, true, promise);
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onHeadersRead(eq(ctx), eq(1), eq(headers), eq(2), eq((short) 3), eq(true), eq(0),
|
verify(listener).onHeadersRead(eq(ctx), eq(1), eq(headers), eq(2), eq((short) 3), eq(true), eq(0),
|
||||||
eq(true));
|
eq(true));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
@ -272,8 +272,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
Http2Headers headers = largeHeaders();
|
Http2Headers headers = largeHeaders();
|
||||||
writer.writeHeaders(ctx, 1, headers, 2, (short) 3, true, 0xFF, true, promise);
|
writer.writeHeaders(ctx, 1, headers, 2, (short) 3, true, 0xFF, true, promise);
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onHeadersRead(eq(ctx), eq(1), eq(headers), eq(2), eq((short) 3), eq(true), eq(0xFF),
|
verify(listener).onHeadersRead(eq(ctx), eq(1), eq(headers), eq(2), eq((short) 3), eq(true), eq(0xFF),
|
||||||
eq(true));
|
eq(true));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
@ -283,8 +283,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
Http2Headers headers = Http2Headers.EMPTY_HEADERS;
|
Http2Headers headers = Http2Headers.EMPTY_HEADERS;
|
||||||
writer.writePushPromise(ctx, 1, 2, headers, 0, promise);
|
writer.writePushPromise(ctx, 1, 2, headers, 0, promise);
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onPushPromiseRead(eq(ctx), eq(1), eq(2), eq(headers), eq(0));
|
verify(listener).onPushPromiseRead(eq(ctx), eq(1), eq(2), eq(headers), eq(0));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,8 +293,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
Http2Headers headers = dummyHeaders();
|
Http2Headers headers = dummyHeaders();
|
||||||
writer.writePushPromise(ctx, 1, 2, headers, 0, promise);
|
writer.writePushPromise(ctx, 1, 2, headers, 0, promise);
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onPushPromiseRead(eq(ctx), eq(1), eq(2), eq(headers), eq(0));
|
verify(listener).onPushPromiseRead(eq(ctx), eq(1), eq(2), eq(headers), eq(0));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,8 +303,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
Http2Headers headers = dummyHeaders();
|
Http2Headers headers = dummyHeaders();
|
||||||
writer.writePushPromise(ctx, 1, 2, headers, 0xFF, promise);
|
writer.writePushPromise(ctx, 1, 2, headers, 0xFF, promise);
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onPushPromiseRead(eq(ctx), eq(1), eq(2), eq(headers), eq(0xFF));
|
verify(listener).onPushPromiseRead(eq(ctx), eq(1), eq(2), eq(headers), eq(0xFF));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,8 +313,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
Http2Headers headers = largeHeaders();
|
Http2Headers headers = largeHeaders();
|
||||||
writer.writePushPromise(ctx, 1, 2, headers, 0, promise);
|
writer.writePushPromise(ctx, 1, 2, headers, 0, promise);
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onPushPromiseRead(eq(ctx), eq(1), eq(2), eq(headers), eq(0));
|
verify(listener).onPushPromiseRead(eq(ctx), eq(1), eq(2), eq(headers), eq(0));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,8 +323,8 @@ public class DefaultHttp2FrameIOTest {
|
|||||||
Http2Headers headers = largeHeaders();
|
Http2Headers headers = largeHeaders();
|
||||||
writer.writePushPromise(ctx, 1, 2, headers, 0xFF, promise);
|
writer.writePushPromise(ctx, 1, 2, headers, 0xFF, promise);
|
||||||
ByteBuf frame = captureWrite();
|
ByteBuf frame = captureWrite();
|
||||||
reader.readFrame(ctx, frame, observer);
|
reader.readFrame(ctx, frame, listener);
|
||||||
verify(observer).onPushPromiseRead(eq(ctx), eq(1), eq(2), eq(headers), eq(0xFF));
|
verify(listener).onPushPromiseRead(eq(ctx), eq(1), eq(2), eq(headers), eq(0xFF));
|
||||||
frame.release();
|
frame.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
private Http2Stream pushStream;
|
private Http2Stream pushStream;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private Http2FrameObserver observer;
|
private Http2FrameListener listener;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private Http2FrameReader reader;
|
private Http2FrameReader reader;
|
||||||
@ -139,7 +139,7 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
|
|
||||||
handler =
|
handler =
|
||||||
new DelegatingHttp2ConnectionHandler(connection, reader, writer, inboundFlow,
|
new DelegatingHttp2ConnectionHandler(connection, reader, writer, inboundFlow,
|
||||||
outboundFlow, observer);
|
outboundFlow, listener);
|
||||||
|
|
||||||
// Simulate activation of the handler to force writing the initial settings.
|
// Simulate activation of the handler to force writing the initial settings.
|
||||||
Http2Settings settings = new Http2Settings();
|
Http2Settings settings = new Http2Settings();
|
||||||
@ -162,7 +162,7 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
|
|
||||||
// Simulate receiving the initial settings from the remote endpoint.
|
// Simulate receiving the initial settings from the remote endpoint.
|
||||||
decode().onSettingsRead(ctx, new Http2Settings());
|
decode().onSettingsRead(ctx, new Http2Settings());
|
||||||
verify(observer).onSettingsRead(eq(ctx), eq(new Http2Settings()));
|
verify(listener).onSettingsRead(eq(ctx), eq(new Http2Settings()));
|
||||||
verify(writer).writeSettingsAck(eq(ctx), eq(promise));
|
verify(writer).writeSettingsAck(eq(ctx), eq(promise));
|
||||||
|
|
||||||
// Simulate receiving the SETTINGS ACK for the initial settings.
|
// Simulate receiving the SETTINGS ACK for the initial settings.
|
||||||
@ -182,7 +182,7 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
public void clientShouldSendClientPrefaceStringWhenActive() throws Exception {
|
public void clientShouldSendClientPrefaceStringWhenActive() throws Exception {
|
||||||
when(connection.isServer()).thenReturn(false);
|
when(connection.isServer()).thenReturn(false);
|
||||||
handler = new DelegatingHttp2ConnectionHandler(connection, reader, writer, inboundFlow,
|
handler = new DelegatingHttp2ConnectionHandler(connection, reader, writer, inboundFlow,
|
||||||
outboundFlow, observer);
|
outboundFlow, listener);
|
||||||
handler.channelActive(ctx);
|
handler.channelActive(ctx);
|
||||||
verify(ctx).write(eq(connectionPrefaceBuf()));
|
verify(ctx).write(eq(connectionPrefaceBuf()));
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
public void serverShouldNotSendClientPrefaceStringWhenActive() throws Exception {
|
public void serverShouldNotSendClientPrefaceStringWhenActive() throws Exception {
|
||||||
when(connection.isServer()).thenReturn(true);
|
when(connection.isServer()).thenReturn(true);
|
||||||
handler = new DelegatingHttp2ConnectionHandler(connection, reader, writer, inboundFlow,
|
handler = new DelegatingHttp2ConnectionHandler(connection, reader, writer, inboundFlow,
|
||||||
outboundFlow, observer);
|
outboundFlow, listener);
|
||||||
handler.channelActive(ctx);
|
handler.channelActive(ctx);
|
||||||
verify(ctx, never()).write(eq(connectionPrefaceBuf()));
|
verify(ctx, never()).write(eq(connectionPrefaceBuf()));
|
||||||
}
|
}
|
||||||
@ -200,21 +200,21 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
public void serverReceivingInvalidClientPrefaceStringShouldCloseConnection() throws Exception {
|
public void serverReceivingInvalidClientPrefaceStringShouldCloseConnection() throws Exception {
|
||||||
when(connection.isServer()).thenReturn(true);
|
when(connection.isServer()).thenReturn(true);
|
||||||
handler = new DelegatingHttp2ConnectionHandler(connection, reader, writer, inboundFlow,
|
handler = new DelegatingHttp2ConnectionHandler(connection, reader, writer, inboundFlow,
|
||||||
outboundFlow, observer);
|
outboundFlow, listener);
|
||||||
handler.channelRead(ctx, copiedBuffer("BAD_PREFACE", UTF_8));
|
handler.channelRead(ctx, copiedBuffer("BAD_PREFACE", UTF_8));
|
||||||
verify(ctx).close();
|
verify(ctx).close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void serverReceivingValidClientPrefaceStringShouldContinueReadingFrames() throws Exception {
|
public void serverReceivingValidClientPrefaceStringShouldContinueReadingFrames() throws Exception {
|
||||||
reset(observer);
|
reset(listener);
|
||||||
when(connection.isServer()).thenReturn(true);
|
when(connection.isServer()).thenReturn(true);
|
||||||
handler = new DelegatingHttp2ConnectionHandler(connection, reader, writer, inboundFlow,
|
handler = new DelegatingHttp2ConnectionHandler(connection, reader, writer, inboundFlow,
|
||||||
outboundFlow, observer);
|
outboundFlow, listener);
|
||||||
handler.channelRead(ctx, connectionPrefaceBuf());
|
handler.channelRead(ctx, connectionPrefaceBuf());
|
||||||
verify(ctx, never()).close();
|
verify(ctx, never()).close();
|
||||||
decode().onSettingsRead(ctx, new Http2Settings());
|
decode().onSettingsRead(ctx, new Http2Settings());
|
||||||
verify(observer).onSettingsRead(eq(ctx), eq(new Http2Settings()));
|
verify(listener).onSettingsRead(eq(ctx), eq(new Http2Settings()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -257,7 +257,7 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
verify(inboundFlow).onDataRead(eq(ctx), eq(STREAM_ID), eq(dummyData()), eq(10), eq(true));
|
verify(inboundFlow).onDataRead(eq(ctx), eq(STREAM_ID), eq(dummyData()), eq(10), eq(true));
|
||||||
|
|
||||||
// Verify that the event was absorbed and not propagated to the oberver.
|
// Verify that the event was absorbed and not propagated to the oberver.
|
||||||
verify(observer, never()).onDataRead(eq(ctx), anyInt(), any(ByteBuf.class), anyInt(),
|
verify(listener, never()).onDataRead(eq(ctx), anyInt(), any(ByteBuf.class), anyInt(),
|
||||||
anyBoolean());
|
anyBoolean());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
decode().onDataRead(ctx, STREAM_ID, dummyData(), 10, true);
|
decode().onDataRead(ctx, STREAM_ID, dummyData(), 10, true);
|
||||||
verify(inboundFlow).onDataRead(eq(ctx), eq(STREAM_ID), eq(dummyData()), eq(10), eq(true));
|
verify(inboundFlow).onDataRead(eq(ctx), eq(STREAM_ID), eq(dummyData()), eq(10), eq(true));
|
||||||
verify(stream).closeRemoteSide();
|
verify(stream).closeRemoteSide();
|
||||||
verify(observer).onDataRead(eq(ctx), eq(STREAM_ID), eq(dummyData()), eq(10), eq(true));
|
verify(listener).onDataRead(eq(ctx), eq(STREAM_ID), eq(dummyData()), eq(10), eq(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -276,7 +276,7 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
verify(remote, never()).createStream(eq(STREAM_ID), eq(false));
|
verify(remote, never()).createStream(eq(STREAM_ID), eq(false));
|
||||||
|
|
||||||
// Verify that the event was absorbed and not propagated to the oberver.
|
// Verify that the event was absorbed and not propagated to the oberver.
|
||||||
verify(observer, never()).onHeadersRead(eq(ctx), anyInt(), any(Http2Headers.class),
|
verify(listener, never()).onHeadersRead(eq(ctx), anyInt(), any(Http2Headers.class),
|
||||||
anyInt(), anyBoolean());
|
anyInt(), anyBoolean());
|
||||||
verify(remote, never()).createStream(anyInt(), anyBoolean());
|
verify(remote, never()).createStream(anyInt(), anyBoolean());
|
||||||
}
|
}
|
||||||
@ -286,7 +286,7 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
when(remote.createStream(eq(5), eq(false))).thenReturn(stream);
|
when(remote.createStream(eq(5), eq(false))).thenReturn(stream);
|
||||||
decode().onHeadersRead(ctx, 5, EMPTY_HEADERS, 0, false);
|
decode().onHeadersRead(ctx, 5, EMPTY_HEADERS, 0, false);
|
||||||
verify(remote).createStream(eq(5), eq(false));
|
verify(remote).createStream(eq(5), eq(false));
|
||||||
verify(observer).onHeadersRead(eq(ctx), eq(5), eq(EMPTY_HEADERS), eq(0),
|
verify(listener).onHeadersRead(eq(ctx), eq(5), eq(EMPTY_HEADERS), eq(0),
|
||||||
eq(DEFAULT_PRIORITY_WEIGHT), eq(false), eq(0), eq(false));
|
eq(DEFAULT_PRIORITY_WEIGHT), eq(false), eq(0), eq(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,7 +295,7 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
when(remote.createStream(eq(5), eq(true))).thenReturn(stream);
|
when(remote.createStream(eq(5), eq(true))).thenReturn(stream);
|
||||||
decode().onHeadersRead(ctx, 5, EMPTY_HEADERS, 0, true);
|
decode().onHeadersRead(ctx, 5, EMPTY_HEADERS, 0, true);
|
||||||
verify(remote).createStream(eq(5), eq(true));
|
verify(remote).createStream(eq(5), eq(true));
|
||||||
verify(observer).onHeadersRead(eq(ctx), eq(5), eq(EMPTY_HEADERS), eq(0),
|
verify(listener).onHeadersRead(eq(ctx), eq(5), eq(EMPTY_HEADERS), eq(0),
|
||||||
eq(DEFAULT_PRIORITY_WEIGHT), eq(false), eq(0), eq(true));
|
eq(DEFAULT_PRIORITY_WEIGHT), eq(false), eq(0), eq(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
when(stream.state()).thenReturn(RESERVED_REMOTE);
|
when(stream.state()).thenReturn(RESERVED_REMOTE);
|
||||||
decode().onHeadersRead(ctx, STREAM_ID, EMPTY_HEADERS, 0, false);
|
decode().onHeadersRead(ctx, STREAM_ID, EMPTY_HEADERS, 0, false);
|
||||||
verify(stream).openForPush();
|
verify(stream).openForPush();
|
||||||
verify(observer).onHeadersRead(eq(ctx), eq(STREAM_ID), eq(EMPTY_HEADERS), eq(0),
|
verify(listener).onHeadersRead(eq(ctx), eq(STREAM_ID), eq(EMPTY_HEADERS), eq(0),
|
||||||
eq(DEFAULT_PRIORITY_WEIGHT), eq(false), eq(0), eq(false));
|
eq(DEFAULT_PRIORITY_WEIGHT), eq(false), eq(0), eq(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
decode().onHeadersRead(ctx, STREAM_ID, EMPTY_HEADERS, 0, true);
|
decode().onHeadersRead(ctx, STREAM_ID, EMPTY_HEADERS, 0, true);
|
||||||
verify(stream).openForPush();
|
verify(stream).openForPush();
|
||||||
verify(stream).close();
|
verify(stream).close();
|
||||||
verify(observer).onHeadersRead(eq(ctx), eq(STREAM_ID), eq(EMPTY_HEADERS), eq(0),
|
verify(listener).onHeadersRead(eq(ctx), eq(STREAM_ID), eq(EMPTY_HEADERS), eq(0),
|
||||||
eq(DEFAULT_PRIORITY_WEIGHT), eq(false), eq(0), eq(true));
|
eq(DEFAULT_PRIORITY_WEIGHT), eq(false), eq(0), eq(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
when(remote.isGoAwayReceived()).thenReturn(true);
|
when(remote.isGoAwayReceived()).thenReturn(true);
|
||||||
decode().onPushPromiseRead(ctx, STREAM_ID, PUSH_STREAM_ID, EMPTY_HEADERS, 0);
|
decode().onPushPromiseRead(ctx, STREAM_ID, PUSH_STREAM_ID, EMPTY_HEADERS, 0);
|
||||||
verify(remote, never()).reservePushStream(anyInt(), any(Http2Stream.class));
|
verify(remote, never()).reservePushStream(anyInt(), any(Http2Stream.class));
|
||||||
verify(observer, never()).onPushPromiseRead(eq(ctx), anyInt(), anyInt(),
|
verify(listener, never()).onPushPromiseRead(eq(ctx), anyInt(), anyInt(),
|
||||||
any(Http2Headers.class), anyInt());
|
any(Http2Headers.class), anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,7 +331,7 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
public void pushPromiseReadShouldSucceed() throws Exception {
|
public void pushPromiseReadShouldSucceed() throws Exception {
|
||||||
decode().onPushPromiseRead(ctx, STREAM_ID, PUSH_STREAM_ID, EMPTY_HEADERS, 0);
|
decode().onPushPromiseRead(ctx, STREAM_ID, PUSH_STREAM_ID, EMPTY_HEADERS, 0);
|
||||||
verify(remote).reservePushStream(eq(PUSH_STREAM_ID), eq(stream));
|
verify(remote).reservePushStream(eq(PUSH_STREAM_ID), eq(stream));
|
||||||
verify(observer).onPushPromiseRead(eq(ctx), eq(STREAM_ID), eq(PUSH_STREAM_ID),
|
verify(listener).onPushPromiseRead(eq(ctx), eq(STREAM_ID), eq(PUSH_STREAM_ID),
|
||||||
eq(EMPTY_HEADERS), eq(0));
|
eq(EMPTY_HEADERS), eq(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,14 +340,14 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
when(remote.isGoAwayReceived()).thenReturn(true);
|
when(remote.isGoAwayReceived()).thenReturn(true);
|
||||||
decode().onPriorityRead(ctx, STREAM_ID, 0, (short) 255, true);
|
decode().onPriorityRead(ctx, STREAM_ID, 0, (short) 255, true);
|
||||||
verify(stream, never()).setPriority(anyInt(), anyShort(), anyBoolean());
|
verify(stream, never()).setPriority(anyInt(), anyShort(), anyBoolean());
|
||||||
verify(observer, never()).onPriorityRead(eq(ctx), anyInt(), anyInt(), anyShort(), anyBoolean());
|
verify(listener, never()).onPriorityRead(eq(ctx), anyInt(), anyInt(), anyShort(), anyBoolean());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void priorityReadShouldSucceed() throws Exception {
|
public void priorityReadShouldSucceed() throws Exception {
|
||||||
decode().onPriorityRead(ctx, STREAM_ID, 0, (short) 255, true);
|
decode().onPriorityRead(ctx, STREAM_ID, 0, (short) 255, true);
|
||||||
verify(stream).setPriority(eq(0), eq((short) 255), eq(true));
|
verify(stream).setPriority(eq(0), eq((short) 255), eq(true));
|
||||||
verify(observer).onPriorityRead(eq(ctx), eq(STREAM_ID), eq(0), eq((short) 255), eq(true));
|
verify(listener).onPriorityRead(eq(ctx), eq(STREAM_ID), eq(0), eq((short) 255), eq(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -355,7 +355,7 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
when(remote.isGoAwayReceived()).thenReturn(true);
|
when(remote.isGoAwayReceived()).thenReturn(true);
|
||||||
decode().onWindowUpdateRead(ctx, STREAM_ID, 10);
|
decode().onWindowUpdateRead(ctx, STREAM_ID, 10);
|
||||||
verify(outboundFlow, never()).updateOutboundWindowSize(anyInt(), anyInt());
|
verify(outboundFlow, never()).updateOutboundWindowSize(anyInt(), anyInt());
|
||||||
verify(observer, never()).onWindowUpdateRead(eq(ctx), anyInt(), anyInt());
|
verify(listener, never()).onWindowUpdateRead(eq(ctx), anyInt(), anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = Http2Exception.class)
|
@Test(expected = Http2Exception.class)
|
||||||
@ -368,7 +368,7 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
public void windowUpdateReadShouldSucceed() throws Exception {
|
public void windowUpdateReadShouldSucceed() throws Exception {
|
||||||
decode().onWindowUpdateRead(ctx, STREAM_ID, 10);
|
decode().onWindowUpdateRead(ctx, STREAM_ID, 10);
|
||||||
verify(outboundFlow).updateOutboundWindowSize(eq(STREAM_ID), eq(10));
|
verify(outboundFlow).updateOutboundWindowSize(eq(STREAM_ID), eq(10));
|
||||||
verify(observer).onWindowUpdateRead(eq(ctx), eq(STREAM_ID), eq(10));
|
verify(listener).onWindowUpdateRead(eq(ctx), eq(STREAM_ID), eq(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -376,7 +376,7 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
when(remote.isGoAwayReceived()).thenReturn(true);
|
when(remote.isGoAwayReceived()).thenReturn(true);
|
||||||
decode().onRstStreamRead(ctx, STREAM_ID, PROTOCOL_ERROR.code());
|
decode().onRstStreamRead(ctx, STREAM_ID, PROTOCOL_ERROR.code());
|
||||||
verify(stream).close();
|
verify(stream).close();
|
||||||
verify(observer).onRstStreamRead(eq(ctx), anyInt(), anyLong());
|
verify(listener).onRstStreamRead(eq(ctx), anyInt(), anyLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = Http2Exception.class)
|
@Test(expected = Http2Exception.class)
|
||||||
@ -389,27 +389,27 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
public void rstStreamReadShouldCloseStream() throws Exception {
|
public void rstStreamReadShouldCloseStream() throws Exception {
|
||||||
decode().onRstStreamRead(ctx, STREAM_ID, PROTOCOL_ERROR.code());
|
decode().onRstStreamRead(ctx, STREAM_ID, PROTOCOL_ERROR.code());
|
||||||
verify(stream).close();
|
verify(stream).close();
|
||||||
verify(observer).onRstStreamRead(eq(ctx), eq(STREAM_ID), eq((long) PROTOCOL_ERROR.code()));
|
verify(listener).onRstStreamRead(eq(ctx), eq(STREAM_ID), eq((long) PROTOCOL_ERROR.code()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void pingReadWithAckShouldNotifyObserver() throws Exception {
|
public void pingReadWithAckShouldNotifylistener() throws Exception {
|
||||||
decode().onPingAckRead(ctx, emptyPingBuf());
|
decode().onPingAckRead(ctx, emptyPingBuf());
|
||||||
verify(observer).onPingAckRead(eq(ctx), eq(emptyPingBuf()));
|
verify(listener).onPingAckRead(eq(ctx), eq(emptyPingBuf()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void pingReadShouldReplyWithAck() throws Exception {
|
public void pingReadShouldReplyWithAck() throws Exception {
|
||||||
decode().onPingRead(ctx, emptyPingBuf());
|
decode().onPingRead(ctx, emptyPingBuf());
|
||||||
verify(writer).writePing(eq(ctx), eq(true), eq(emptyPingBuf()), eq(promise));
|
verify(writer).writePing(eq(ctx), eq(true), eq(emptyPingBuf()), eq(promise));
|
||||||
verify(observer, never()).onPingAckRead(eq(ctx), any(ByteBuf.class));
|
verify(listener, never()).onPingAckRead(eq(ctx), any(ByteBuf.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void settingsReadWithAckShouldNotifyObserver() throws Exception {
|
public void settingsReadWithAckShouldNotifylistener() throws Exception {
|
||||||
decode().onSettingsAckRead(ctx);
|
decode().onSettingsAckRead(ctx);
|
||||||
// Take into account the time this was called during setup().
|
// Take into account the time this was called during setup().
|
||||||
verify(observer, times(2)).onSettingsAckRead(eq(ctx));
|
verify(listener, times(2)).onSettingsAckRead(eq(ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = Http2Exception.class)
|
@Test(expected = Http2Exception.class)
|
||||||
@ -435,14 +435,14 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
verify(writer).maxHeaderTableSize(789L);
|
verify(writer).maxHeaderTableSize(789L);
|
||||||
// Take into account the time this was called during setup().
|
// Take into account the time this was called during setup().
|
||||||
verify(writer, times(2)).writeSettingsAck(eq(ctx), eq(promise));
|
verify(writer, times(2)).writeSettingsAck(eq(ctx), eq(promise));
|
||||||
verify(observer).onSettingsRead(eq(ctx), eq(settings));
|
verify(listener).onSettingsRead(eq(ctx), eq(settings));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void goAwayShouldReadShouldUpdateConnectionState() throws Exception {
|
public void goAwayShouldReadShouldUpdateConnectionState() throws Exception {
|
||||||
decode().onGoAwayRead(ctx, 1, 2L, EMPTY_BUFFER);
|
decode().onGoAwayRead(ctx, 1, 2L, EMPTY_BUFFER);
|
||||||
verify(local).goAwayReceived(1);
|
verify(local).goAwayReceived(1);
|
||||||
verify(observer).onGoAwayRead(eq(ctx), eq(1), eq(2L), eq(EMPTY_BUFFER));
|
verify(listener).onGoAwayRead(eq(ctx), eq(1), eq(2L), eq(EMPTY_BUFFER));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -608,13 +608,13 @@ public class DelegatingHttp2ConnectionHandlerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls the decode method on the handler and gets back the captured internal observer
|
* Calls the decode method on the handler and gets back the captured internal listener
|
||||||
*/
|
*/
|
||||||
private Http2FrameObserver decode() throws Exception {
|
private Http2FrameListener decode() throws Exception {
|
||||||
ArgumentCaptor<Http2FrameObserver> internalObserver =
|
ArgumentCaptor<Http2FrameListener> internallistener =
|
||||||
ArgumentCaptor.forClass(Http2FrameObserver.class);
|
ArgumentCaptor.forClass(Http2FrameListener.class);
|
||||||
doNothing().when(reader).readFrame(eq(ctx), any(ByteBuf.class), internalObserver.capture());
|
doNothing().when(reader).readFrame(eq(ctx), any(ByteBuf.class), internallistener.capture());
|
||||||
handler.decode(ctx, EMPTY_BUFFER, Collections.emptyList());
|
handler.decode(ctx, EMPTY_BUFFER, Collections.emptyList());
|
||||||
return internalObserver.getValue();
|
return internallistener.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,10 +62,10 @@ import org.mockito.MockitoAnnotations;
|
|||||||
public class DelegatingHttp2HttpConnectionHandlerTest {
|
public class DelegatingHttp2HttpConnectionHandlerTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private Http2FrameObserver clientObserver;
|
private Http2FrameListener clientListener;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private Http2FrameObserver serverObserver;
|
private Http2FrameListener serverListener;
|
||||||
|
|
||||||
private ServerBootstrap sb;
|
private ServerBootstrap sb;
|
||||||
private Bootstrap cb;
|
private Bootstrap cb;
|
||||||
@ -100,7 +100,7 @@ public class DelegatingHttp2HttpConnectionHandlerTest {
|
|||||||
@Override
|
@Override
|
||||||
protected void initChannel(Channel ch) throws Exception {
|
protected void initChannel(Channel ch) throws Exception {
|
||||||
ChannelPipeline p = ch.pipeline();
|
ChannelPipeline p = ch.pipeline();
|
||||||
p.addLast(new DelegatingHttp2HttpConnectionHandler(false, clientObserver));
|
p.addLast(new DelegatingHttp2HttpConnectionHandler(false, clientListener));
|
||||||
p.addLast(ignoreSettingsHandler());
|
p.addLast(ignoreSettingsHandler());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -142,9 +142,9 @@ public class DelegatingHttp2HttpConnectionHandlerTest {
|
|||||||
writeFuture.awaitUninterruptibly(2, SECONDS);
|
writeFuture.awaitUninterruptibly(2, SECONDS);
|
||||||
assertTrue(writeFuture.isSuccess());
|
assertTrue(writeFuture.isSuccess());
|
||||||
awaitRequests();
|
awaitRequests();
|
||||||
verify(serverObserver).onHeadersRead(any(ChannelHandlerContext.class), eq(5), eq(http2Headers), eq(0),
|
verify(serverListener).onHeadersRead(any(ChannelHandlerContext.class), eq(5), eq(http2Headers), eq(0),
|
||||||
anyShort(), anyBoolean(), eq(0), eq(true));
|
anyShort(), anyBoolean(), eq(0), eq(true));
|
||||||
verify(serverObserver, never()).onDataRead(any(ChannelHandlerContext.class),
|
verify(serverListener, never()).onDataRead(any(ChannelHandlerContext.class),
|
||||||
anyInt(), any(ByteBuf.class), anyInt(), anyBoolean());
|
anyInt(), any(ByteBuf.class), anyInt(), anyBoolean());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,9 +170,9 @@ public class DelegatingHttp2HttpConnectionHandlerTest {
|
|||||||
writeFuture.awaitUninterruptibly(2, SECONDS);
|
writeFuture.awaitUninterruptibly(2, SECONDS);
|
||||||
assertTrue(writeFuture.isSuccess());
|
assertTrue(writeFuture.isSuccess());
|
||||||
awaitRequests();
|
awaitRequests();
|
||||||
verify(serverObserver).onHeadersRead(any(ChannelHandlerContext.class), eq(3), eq(http2Headers), eq(0),
|
verify(serverListener).onHeadersRead(any(ChannelHandlerContext.class), eq(3), eq(http2Headers), eq(0),
|
||||||
anyShort(), anyBoolean(), eq(0), eq(false));
|
anyShort(), anyBoolean(), eq(0), eq(false));
|
||||||
verify(serverObserver).onDataRead(any(ChannelHandlerContext.class),
|
verify(serverListener).onDataRead(any(ChannelHandlerContext.class),
|
||||||
eq(3), eq(Unpooled.copiedBuffer(text.getBytes())), eq(0), eq(true));
|
eq(3), eq(Unpooled.copiedBuffer(text.getBytes())), eq(0), eq(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,20 +192,20 @@ public class DelegatingHttp2HttpConnectionHandlerTest {
|
|||||||
* A decorator around the serverObserver that counts down the latch so that we can await the
|
* A decorator around the serverObserver that counts down the latch so that we can await the
|
||||||
* completion of the request.
|
* completion of the request.
|
||||||
*/
|
*/
|
||||||
private final class FrameCountDown implements Http2FrameObserver {
|
private final class FrameCountDown implements Http2FrameListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding,
|
public void onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding,
|
||||||
boolean endOfStream)
|
boolean endOfStream)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
serverObserver.onDataRead(ctx, streamId, copy(data), padding, endOfStream);
|
serverListener.onDataRead(ctx, streamId, copy(data), padding, endOfStream);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers,
|
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers,
|
||||||
int padding, boolean endStream) throws Http2Exception {
|
int padding, boolean endStream) throws Http2Exception {
|
||||||
serverObserver.onHeadersRead(ctx, streamId, headers, padding, endStream);
|
serverListener.onHeadersRead(ctx, streamId, headers, padding, endStream);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ public class DelegatingHttp2HttpConnectionHandlerTest {
|
|||||||
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers,
|
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers,
|
||||||
int streamDependency, short weight, boolean exclusive, int padding,
|
int streamDependency, short weight, boolean exclusive, int padding,
|
||||||
boolean endStream) throws Http2Exception {
|
boolean endStream) throws Http2Exception {
|
||||||
serverObserver.onHeadersRead(ctx, streamId, headers, streamDependency, weight,
|
serverListener.onHeadersRead(ctx, streamId, headers, streamDependency, weight,
|
||||||
exclusive, padding, endStream);
|
exclusive, padding, endStream);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
@ -221,66 +221,66 @@ public class DelegatingHttp2HttpConnectionHandlerTest {
|
|||||||
@Override
|
@Override
|
||||||
public void onPriorityRead(ChannelHandlerContext ctx, int streamId, int streamDependency,
|
public void onPriorityRead(ChannelHandlerContext ctx, int streamId, int streamDependency,
|
||||||
short weight, boolean exclusive) throws Http2Exception {
|
short weight, boolean exclusive) throws Http2Exception {
|
||||||
serverObserver.onPriorityRead(ctx, streamId, streamDependency, weight, exclusive);
|
serverListener.onPriorityRead(ctx, streamId, streamDependency, weight, exclusive);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode)
|
public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
serverObserver.onRstStreamRead(ctx, streamId, errorCode);
|
serverListener.onRstStreamRead(ctx, streamId, errorCode);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSettingsAckRead(ChannelHandlerContext ctx) throws Http2Exception {
|
public void onSettingsAckRead(ChannelHandlerContext ctx) throws Http2Exception {
|
||||||
serverObserver.onSettingsAckRead(ctx);
|
serverListener.onSettingsAckRead(ctx);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) throws Http2Exception {
|
public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) throws Http2Exception {
|
||||||
serverObserver.onSettingsRead(ctx, settings);
|
serverListener.onSettingsRead(ctx, settings);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPingRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
public void onPingRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
||||||
serverObserver.onPingRead(ctx, copy(data));
|
serverListener.onPingRead(ctx, copy(data));
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPingAckRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
public void onPingAckRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
||||||
serverObserver.onPingAckRead(ctx, copy(data));
|
serverListener.onPingAckRead(ctx, copy(data));
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId,
|
public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId,
|
||||||
int promisedStreamId, Http2Headers headers, int padding) throws Http2Exception {
|
int promisedStreamId, Http2Headers headers, int padding) throws Http2Exception {
|
||||||
serverObserver.onPushPromiseRead(ctx, streamId, promisedStreamId, headers, padding);
|
serverListener.onPushPromiseRead(ctx, streamId, promisedStreamId, headers, padding);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGoAwayRead(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData)
|
public void onGoAwayRead(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
serverObserver.onGoAwayRead(ctx, lastStreamId, errorCode, copy(debugData));
|
serverListener.onGoAwayRead(ctx, lastStreamId, errorCode, copy(debugData));
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWindowUpdateRead(ChannelHandlerContext ctx, int streamId,
|
public void onWindowUpdateRead(ChannelHandlerContext ctx, int streamId,
|
||||||
int windowSizeIncrement) throws Http2Exception {
|
int windowSizeIncrement) throws Http2Exception {
|
||||||
serverObserver.onWindowUpdateRead(ctx, streamId, windowSizeIncrement);
|
serverListener.onWindowUpdateRead(ctx, streamId, windowSizeIncrement);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUnknownFrame(ChannelHandlerContext ctx, byte frameType, int streamId,
|
public void onUnknownFrame(ChannelHandlerContext ctx, byte frameType, int streamId,
|
||||||
Http2Flags flags, ByteBuf payload) {
|
Http2Flags flags, ByteBuf payload) {
|
||||||
serverObserver.onUnknownFrame(ctx, frameType, streamId, flags, payload);
|
serverListener.onUnknownFrame(ctx, frameType, streamId, flags, payload);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,10 +49,10 @@ import static org.mockito.Mockito.*;
|
|||||||
public class Http2ConnectionRoundtripTest {
|
public class Http2ConnectionRoundtripTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private Http2FrameObserver clientObserver;
|
private Http2FrameListener clientListener;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private Http2FrameObserver serverObserver;
|
private Http2FrameListener serverListener;
|
||||||
|
|
||||||
private DelegatingHttp2ConnectionHandler http2Client;
|
private DelegatingHttp2ConnectionHandler http2Client;
|
||||||
private ServerBootstrap sb;
|
private ServerBootstrap sb;
|
||||||
@ -86,7 +86,7 @@ public class Http2ConnectionRoundtripTest {
|
|||||||
@Override
|
@Override
|
||||||
protected void initChannel(Channel ch) throws Exception {
|
protected void initChannel(Channel ch) throws Exception {
|
||||||
ChannelPipeline p = ch.pipeline();
|
ChannelPipeline p = ch.pipeline();
|
||||||
p.addLast(new DelegatingHttp2ConnectionHandler(false, clientObserver));
|
p.addLast(new DelegatingHttp2ConnectionHandler(false, clientListener));
|
||||||
p.addLast(Http2CodecUtil.ignoreSettingsHandler());
|
p.addLast(Http2CodecUtil.ignoreSettingsHandler());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -129,11 +129,11 @@ public class Http2ConnectionRoundtripTest {
|
|||||||
});
|
});
|
||||||
// Wait for all frames to be received.
|
// Wait for all frames to be received.
|
||||||
awaitRequests();
|
awaitRequests();
|
||||||
verify(serverObserver, times(NUM_STREAMS)).onHeadersRead(any(ChannelHandlerContext.class),
|
verify(serverListener, times(NUM_STREAMS)).onHeadersRead(any(ChannelHandlerContext.class),
|
||||||
anyInt(), eq(headers), eq(0), eq((short) 16), eq(false), eq(0), eq(false));
|
anyInt(), eq(headers), eq(0), eq((short) 16), eq(false), eq(0), eq(false));
|
||||||
verify(serverObserver, times(NUM_STREAMS)).onPingRead(any(ChannelHandlerContext.class),
|
verify(serverListener, times(NUM_STREAMS)).onPingRead(any(ChannelHandlerContext.class),
|
||||||
eq(Unpooled.copiedBuffer(pingMsg.getBytes())));
|
eq(Unpooled.copiedBuffer(pingMsg.getBytes())));
|
||||||
verify(serverObserver, times(NUM_STREAMS)).onDataRead(any(ChannelHandlerContext.class),
|
verify(serverListener, times(NUM_STREAMS)).onDataRead(any(ChannelHandlerContext.class),
|
||||||
anyInt(), eq(Unpooled.copiedBuffer(text.getBytes())), eq(0), eq(true));
|
anyInt(), eq(Unpooled.copiedBuffer(text.getBytes())), eq(0), eq(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,20 +153,20 @@ public class Http2ConnectionRoundtripTest {
|
|||||||
* A decorator around the serverObserver that counts down the latch so that we can await the
|
* A decorator around the serverObserver that counts down the latch so that we can await the
|
||||||
* completion of the request.
|
* completion of the request.
|
||||||
*/
|
*/
|
||||||
private final class FrameCountDown implements Http2FrameObserver {
|
private final class FrameCountDown implements Http2FrameListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding,
|
public void onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding,
|
||||||
boolean endOfStream)
|
boolean endOfStream)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
serverObserver.onDataRead(ctx, streamId, copy(data), padding, endOfStream);
|
serverListener.onDataRead(ctx, streamId, copy(data), padding, endOfStream);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers,
|
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers,
|
||||||
int padding, boolean endStream) throws Http2Exception {
|
int padding, boolean endStream) throws Http2Exception {
|
||||||
serverObserver.onHeadersRead(ctx, streamId, headers, padding, endStream);
|
serverListener.onHeadersRead(ctx, streamId, headers, padding, endStream);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ public class Http2ConnectionRoundtripTest {
|
|||||||
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers,
|
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers,
|
||||||
int streamDependency, short weight, boolean exclusive, int padding,
|
int streamDependency, short weight, boolean exclusive, int padding,
|
||||||
boolean endStream) throws Http2Exception {
|
boolean endStream) throws Http2Exception {
|
||||||
serverObserver.onHeadersRead(ctx, streamId, headers, streamDependency, weight,
|
serverListener.onHeadersRead(ctx, streamId, headers, streamDependency, weight,
|
||||||
exclusive, padding, endStream);
|
exclusive, padding, endStream);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
@ -182,66 +182,66 @@ public class Http2ConnectionRoundtripTest {
|
|||||||
@Override
|
@Override
|
||||||
public void onPriorityRead(ChannelHandlerContext ctx, int streamId, int streamDependency,
|
public void onPriorityRead(ChannelHandlerContext ctx, int streamId, int streamDependency,
|
||||||
short weight, boolean exclusive) throws Http2Exception {
|
short weight, boolean exclusive) throws Http2Exception {
|
||||||
serverObserver.onPriorityRead(ctx, streamId, streamDependency, weight, exclusive);
|
serverListener.onPriorityRead(ctx, streamId, streamDependency, weight, exclusive);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode)
|
public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
serverObserver.onRstStreamRead(ctx, streamId, errorCode);
|
serverListener.onRstStreamRead(ctx, streamId, errorCode);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSettingsAckRead(ChannelHandlerContext ctx) throws Http2Exception {
|
public void onSettingsAckRead(ChannelHandlerContext ctx) throws Http2Exception {
|
||||||
serverObserver.onSettingsAckRead(ctx);
|
serverListener.onSettingsAckRead(ctx);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) throws Http2Exception {
|
public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) throws Http2Exception {
|
||||||
serverObserver.onSettingsRead(ctx, settings);
|
serverListener.onSettingsRead(ctx, settings);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPingRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
public void onPingRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
||||||
serverObserver.onPingRead(ctx, copy(data));
|
serverListener.onPingRead(ctx, copy(data));
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPingAckRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
public void onPingAckRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
||||||
serverObserver.onPingAckRead(ctx, copy(data));
|
serverListener.onPingAckRead(ctx, copy(data));
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId,
|
public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId,
|
||||||
int promisedStreamId, Http2Headers headers, int padding) throws Http2Exception {
|
int promisedStreamId, Http2Headers headers, int padding) throws Http2Exception {
|
||||||
serverObserver.onPushPromiseRead(ctx, streamId, promisedStreamId, headers, padding);
|
serverListener.onPushPromiseRead(ctx, streamId, promisedStreamId, headers, padding);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGoAwayRead(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData)
|
public void onGoAwayRead(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
serverObserver.onGoAwayRead(ctx, lastStreamId, errorCode, copy(debugData));
|
serverListener.onGoAwayRead(ctx, lastStreamId, errorCode, copy(debugData));
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWindowUpdateRead(ChannelHandlerContext ctx, int streamId,
|
public void onWindowUpdateRead(ChannelHandlerContext ctx, int streamId,
|
||||||
int windowSizeIncrement) throws Http2Exception {
|
int windowSizeIncrement) throws Http2Exception {
|
||||||
serverObserver.onWindowUpdateRead(ctx, streamId, windowSizeIncrement);
|
serverListener.onWindowUpdateRead(ctx, streamId, windowSizeIncrement);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUnknownFrame(ChannelHandlerContext ctx, byte frameType, int streamId,
|
public void onUnknownFrame(ChannelHandlerContext ctx, byte frameType, int streamId,
|
||||||
Http2Flags flags, ByteBuf payload) {
|
Http2Flags flags, ByteBuf payload) {
|
||||||
serverObserver.onUnknownFrame(ctx, frameType, streamId, flags, payload);
|
serverListener.onUnknownFrame(ctx, frameType, streamId, flags, payload);
|
||||||
requestLatch.countDown();
|
requestLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ import static org.mockito.Mockito.*;
|
|||||||
public class Http2FrameRoundtripTest {
|
public class Http2FrameRoundtripTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private Http2FrameObserver serverObserver;
|
private Http2FrameListener serverObserver;
|
||||||
|
|
||||||
private ArgumentCaptor<ByteBuf> dataCaptor;
|
private ArgumentCaptor<ByteBuf> dataCaptor;
|
||||||
private Http2FrameWriter frameWriter;
|
private Http2FrameWriter frameWriter;
|
||||||
@ -308,10 +308,10 @@ public class Http2FrameRoundtripTest {
|
|||||||
|
|
||||||
private final class FrameAdapter extends ByteToMessageDecoder {
|
private final class FrameAdapter extends ByteToMessageDecoder {
|
||||||
|
|
||||||
private final Http2FrameObserver observer;
|
private final Http2FrameListener observer;
|
||||||
private final DefaultHttp2FrameReader reader;
|
private final DefaultHttp2FrameReader reader;
|
||||||
|
|
||||||
FrameAdapter(Http2FrameObserver observer) {
|
FrameAdapter(Http2FrameListener observer) {
|
||||||
this.observer = observer;
|
this.observer = observer;
|
||||||
reader = new DefaultHttp2FrameReader();
|
reader = new DefaultHttp2FrameReader();
|
||||||
}
|
}
|
||||||
@ -319,7 +319,7 @@ public class Http2FrameRoundtripTest {
|
|||||||
@Override
|
@Override
|
||||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out)
|
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
reader.readFrame(ctx, in, new Http2FrameObserver() {
|
reader.readFrame(ctx, in, new Http2FrameListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data,
|
public void onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data,
|
||||||
|
@ -69,10 +69,10 @@ import org.mockito.MockitoAnnotations;
|
|||||||
public class InboundHttp2ToHttpAdapterTest {
|
public class InboundHttp2ToHttpAdapterTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private HttpResponseListener serverObserver;
|
private HttpResponseListener serverListener;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private HttpResponseListener clientObserver;
|
private HttpResponseListener clientListener;
|
||||||
|
|
||||||
private Http2FrameWriter frameWriter;
|
private Http2FrameWriter frameWriter;
|
||||||
private ServerBootstrap sb;
|
private ServerBootstrap sb;
|
||||||
@ -111,7 +111,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
p.addLast("reader", new FrameAdapter(connection,
|
p.addLast("reader", new FrameAdapter(connection,
|
||||||
InboundHttp2ToHttpPriorityAdapter.newInstance(connection, maxContentLength),
|
InboundHttp2ToHttpPriorityAdapter.newInstance(connection, maxContentLength),
|
||||||
new CountDownLatch(10)));
|
new CountDownLatch(10)));
|
||||||
serverDelegator = new HttpResponseDelegator(serverObserver, serverLatch);
|
serverDelegator = new HttpResponseDelegator(serverListener, serverLatch);
|
||||||
p.addLast(serverDelegator);
|
p.addLast(serverDelegator);
|
||||||
serverConnectedChannel = ch;
|
serverConnectedChannel = ch;
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
p.addLast("reader", new FrameAdapter(connection,
|
p.addLast("reader", new FrameAdapter(connection,
|
||||||
InboundHttp2ToHttpPriorityAdapter.newInstance(connection, maxContentLength),
|
InboundHttp2ToHttpPriorityAdapter.newInstance(connection, maxContentLength),
|
||||||
new CountDownLatch(10)));
|
new CountDownLatch(10)));
|
||||||
clientDelegator = new HttpResponseDelegator(clientObserver, clientLatch);
|
clientDelegator = new HttpResponseDelegator(clientListener, clientLatch);
|
||||||
p.addLast(clientDelegator);
|
p.addLast(clientDelegator);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -171,7 +171,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
awaitRequests();
|
awaitRequests();
|
||||||
verify(serverObserver).messageReceived(eq(request));
|
verify(serverListener).messageReceived(eq(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -195,7 +195,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
awaitRequests();
|
awaitRequests();
|
||||||
verify(serverObserver).messageReceived(eq(request));
|
verify(serverListener).messageReceived(eq(request));
|
||||||
request.release();
|
request.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
awaitRequests();
|
awaitRequests();
|
||||||
verify(serverObserver).messageReceived(eq(request));
|
verify(serverListener).messageReceived(eq(request));
|
||||||
request.release();
|
request.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
awaitRequests();
|
awaitRequests();
|
||||||
verify(serverObserver).messageReceived(eq(request));
|
verify(serverListener).messageReceived(eq(request));
|
||||||
request.release();
|
request.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
awaitRequests();
|
awaitRequests();
|
||||||
verify(serverObserver).messageReceived(eq(request));
|
verify(serverListener).messageReceived(eq(request));
|
||||||
request.release();
|
request.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
awaitRequests();
|
awaitRequests();
|
||||||
verify(serverObserver).messageReceived(eq(request));
|
verify(serverListener).messageReceived(eq(request));
|
||||||
request.release();
|
request.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,7 +355,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
});
|
});
|
||||||
awaitRequests();
|
awaitRequests();
|
||||||
ArgumentCaptor<HttpObject> httpObjectCaptor = ArgumentCaptor.forClass(HttpObject.class);
|
ArgumentCaptor<HttpObject> httpObjectCaptor = ArgumentCaptor.forClass(HttpObject.class);
|
||||||
verify(serverObserver, times(2)).messageReceived(httpObjectCaptor.capture());
|
verify(serverListener, times(2)).messageReceived(httpObjectCaptor.capture());
|
||||||
List<HttpObject> capturedHttpObjects = httpObjectCaptor.getAllValues();
|
List<HttpObject> capturedHttpObjects = httpObjectCaptor.getAllValues();
|
||||||
assertEquals(request, capturedHttpObjects.get(0));
|
assertEquals(request, capturedHttpObjects.get(0));
|
||||||
assertEquals(request2, capturedHttpObjects.get(1));
|
assertEquals(request2, capturedHttpObjects.get(1));
|
||||||
@ -406,7 +406,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
});
|
});
|
||||||
awaitRequests();
|
awaitRequests();
|
||||||
ArgumentCaptor<HttpObject> httpObjectCaptor = ArgumentCaptor.forClass(HttpObject.class);
|
ArgumentCaptor<HttpObject> httpObjectCaptor = ArgumentCaptor.forClass(HttpObject.class);
|
||||||
verify(serverObserver, times(3)).messageReceived(httpObjectCaptor.capture());
|
verify(serverListener, times(3)).messageReceived(httpObjectCaptor.capture());
|
||||||
List<HttpObject> capturedHttpObjects = httpObjectCaptor.getAllValues();
|
List<HttpObject> capturedHttpObjects = httpObjectCaptor.getAllValues();
|
||||||
assertEquals(request, capturedHttpObjects.get(0));
|
assertEquals(request, capturedHttpObjects.get(0));
|
||||||
assertEquals(request2, capturedHttpObjects.get(1));
|
assertEquals(request2, capturedHttpObjects.get(1));
|
||||||
@ -450,7 +450,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
awaitRequests();
|
awaitRequests();
|
||||||
verify(serverObserver).messageReceived(eq(request));
|
verify(serverListener).messageReceived(eq(request));
|
||||||
|
|
||||||
final Http2Headers http2Headers = new DefaultHttp2Headers.Builder().status("200").build();
|
final Http2Headers http2Headers = new DefaultHttp2Headers.Builder().status("200").build();
|
||||||
final Http2Headers http2Headers2 = new DefaultHttp2Headers.Builder().status("201").scheme("https")
|
final Http2Headers http2Headers2 = new DefaultHttp2Headers.Builder().status("201").scheme("https")
|
||||||
@ -467,7 +467,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
});
|
});
|
||||||
awaitResponses();
|
awaitResponses();
|
||||||
ArgumentCaptor<HttpObject> httpObjectCaptor = ArgumentCaptor.forClass(HttpObject.class);
|
ArgumentCaptor<HttpObject> httpObjectCaptor = ArgumentCaptor.forClass(HttpObject.class);
|
||||||
verify(clientObserver, times(2)).messageReceived(httpObjectCaptor.capture());
|
verify(clientListener, times(2)).messageReceived(httpObjectCaptor.capture());
|
||||||
List<HttpObject> capturedHttpObjects = httpObjectCaptor.getAllValues();
|
List<HttpObject> capturedHttpObjects = httpObjectCaptor.getAllValues();
|
||||||
assertEquals(response, capturedHttpObjects.get(0));
|
assertEquals(response, capturedHttpObjects.get(0));
|
||||||
assertEquals(response2, capturedHttpObjects.get(1));
|
assertEquals(response2, capturedHttpObjects.get(1));
|
||||||
@ -493,8 +493,8 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
awaitRequests();
|
awaitRequests();
|
||||||
verify(serverObserver).messageReceived(eq(request));
|
verify(serverListener).messageReceived(eq(request));
|
||||||
reset(serverObserver);
|
reset(serverListener);
|
||||||
|
|
||||||
final FullHttpMessage response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.CONTINUE);
|
final FullHttpMessage response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.CONTINUE);
|
||||||
httpHeaders = response.headers();
|
httpHeaders = response.headers();
|
||||||
@ -509,8 +509,8 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
awaitResponses();
|
awaitResponses();
|
||||||
verify(clientObserver).messageReceived(eq(response));
|
verify(clientListener).messageReceived(eq(response));
|
||||||
reset(clientObserver);
|
reset(clientListener);
|
||||||
|
|
||||||
setServerLatch(1);
|
setServerLatch(1);
|
||||||
final String text = "a big payload";
|
final String text = "a big payload";
|
||||||
@ -528,7 +528,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
awaitRequests();
|
awaitRequests();
|
||||||
verify(serverObserver).messageReceived(eq(request2));
|
verify(serverListener).messageReceived(eq(request2));
|
||||||
request2.release();
|
request2.release();
|
||||||
|
|
||||||
setClientLatch(1);
|
setClientLatch(1);
|
||||||
@ -545,7 +545,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
awaitResponses();
|
awaitResponses();
|
||||||
verify(clientObserver).messageReceived(eq(response2));
|
verify(clientListener).messageReceived(eq(response2));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setServerLatch(int count) {
|
private void setServerLatch(int count) {
|
||||||
@ -613,20 +613,20 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
|
|
||||||
private final class FrameAdapter extends ByteToMessageDecoder {
|
private final class FrameAdapter extends ByteToMessageDecoder {
|
||||||
private final Http2Connection connection;
|
private final Http2Connection connection;
|
||||||
private final Http2FrameObserver observer;
|
private final Http2FrameListener listener;
|
||||||
private final DefaultHttp2FrameReader reader;
|
private final DefaultHttp2FrameReader reader;
|
||||||
private final CountDownLatch latch;
|
private final CountDownLatch latch;
|
||||||
|
|
||||||
FrameAdapter(Http2Connection connection, Http2FrameObserver observer, CountDownLatch latch) {
|
FrameAdapter(Http2Connection connection, Http2FrameListener listener, CountDownLatch latch) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.observer = observer;
|
this.listener = listener;
|
||||||
reader = new DefaultHttp2FrameReader();
|
reader = new DefaultHttp2FrameReader();
|
||||||
this.latch = latch;
|
this.latch = latch;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||||
reader.readFrame(ctx, in, new Http2FrameObserver() {
|
reader.readFrame(ctx, in, new Http2FrameListener() {
|
||||||
public Http2Stream getOrCreateStream(int streamId, boolean halfClosed) throws Http2Exception {
|
public Http2Stream getOrCreateStream(int streamId, boolean halfClosed) throws Http2Exception {
|
||||||
Http2Stream stream = connection.stream(streamId);
|
Http2Stream stream = connection.stream(streamId);
|
||||||
if (stream == null) {
|
if (stream == null) {
|
||||||
@ -649,7 +649,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
@Override
|
@Override
|
||||||
public void onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding,
|
public void onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding,
|
||||||
boolean endOfStream) throws Http2Exception {
|
boolean endOfStream) throws Http2Exception {
|
||||||
observer.onDataRead(ctx, streamId, copy(data), padding, endOfStream);
|
listener.onDataRead(ctx, streamId, copy(data), padding, endOfStream);
|
||||||
// NOTE: Do not close the stream to allow the out of order messages to be processed
|
// NOTE: Do not close the stream to allow the out of order messages to be processed
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
@ -658,7 +658,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding,
|
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding,
|
||||||
boolean endStream) throws Http2Exception {
|
boolean endStream) throws Http2Exception {
|
||||||
Http2Stream stream = getOrCreateStream(streamId, endStream);
|
Http2Stream stream = getOrCreateStream(streamId, endStream);
|
||||||
observer.onHeadersRead(ctx, streamId, headers, padding, endStream);
|
listener.onHeadersRead(ctx, streamId, headers, padding, endStream);
|
||||||
if (endStream) {
|
if (endStream) {
|
||||||
closeStream(stream);
|
closeStream(stream);
|
||||||
}
|
}
|
||||||
@ -671,7 +671,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
Http2Stream stream = getOrCreateStream(streamId, endStream);
|
Http2Stream stream = getOrCreateStream(streamId, endStream);
|
||||||
stream.setPriority(streamDependency, weight, exclusive);
|
stream.setPriority(streamDependency, weight, exclusive);
|
||||||
observer.onHeadersRead(ctx, streamId, headers, streamDependency, weight, exclusive, padding,
|
listener.onHeadersRead(ctx, streamId, headers, streamDependency, weight, exclusive, padding,
|
||||||
endStream);
|
endStream);
|
||||||
if (endStream) {
|
if (endStream) {
|
||||||
closeStream(stream);
|
closeStream(stream);
|
||||||
@ -684,7 +684,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
boolean exclusive) throws Http2Exception {
|
boolean exclusive) throws Http2Exception {
|
||||||
Http2Stream stream = getOrCreateStream(streamId, false);
|
Http2Stream stream = getOrCreateStream(streamId, false);
|
||||||
stream.setPriority(streamDependency, weight, exclusive);
|
stream.setPriority(streamDependency, weight, exclusive);
|
||||||
observer.onPriorityRead(ctx, streamId, streamDependency, weight, exclusive);
|
listener.onPriorityRead(ctx, streamId, streamDependency, weight, exclusive);
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -692,32 +692,32 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode)
|
public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
Http2Stream stream = getOrCreateStream(streamId, false);
|
Http2Stream stream = getOrCreateStream(streamId, false);
|
||||||
observer.onRstStreamRead(ctx, streamId, errorCode);
|
listener.onRstStreamRead(ctx, streamId, errorCode);
|
||||||
closeStream(stream);
|
closeStream(stream);
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSettingsAckRead(ChannelHandlerContext ctx) throws Http2Exception {
|
public void onSettingsAckRead(ChannelHandlerContext ctx) throws Http2Exception {
|
||||||
observer.onSettingsAckRead(ctx);
|
listener.onSettingsAckRead(ctx);
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) throws Http2Exception {
|
public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) throws Http2Exception {
|
||||||
observer.onSettingsRead(ctx, settings);
|
listener.onSettingsRead(ctx, settings);
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPingRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
public void onPingRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
||||||
observer.onPingRead(ctx, copy(data));
|
listener.onPingRead(ctx, copy(data));
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPingAckRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
public void onPingAckRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
|
||||||
observer.onPingAckRead(ctx, copy(data));
|
listener.onPingAckRead(ctx, copy(data));
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -725,14 +725,14 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promisedStreamId,
|
public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promisedStreamId,
|
||||||
Http2Headers headers, int padding) throws Http2Exception {
|
Http2Headers headers, int padding) throws Http2Exception {
|
||||||
getOrCreateStream(promisedStreamId, false);
|
getOrCreateStream(promisedStreamId, false);
|
||||||
observer.onPushPromiseRead(ctx, streamId, promisedStreamId, headers, padding);
|
listener.onPushPromiseRead(ctx, streamId, promisedStreamId, headers, padding);
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGoAwayRead(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData)
|
public void onGoAwayRead(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
observer.onGoAwayRead(ctx, lastStreamId, errorCode, copy(debugData));
|
listener.onGoAwayRead(ctx, lastStreamId, errorCode, copy(debugData));
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -740,14 +740,14 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
public void onWindowUpdateRead(ChannelHandlerContext ctx, int streamId, int windowSizeIncrement)
|
public void onWindowUpdateRead(ChannelHandlerContext ctx, int streamId, int windowSizeIncrement)
|
||||||
throws Http2Exception {
|
throws Http2Exception {
|
||||||
getOrCreateStream(streamId, false);
|
getOrCreateStream(streamId, false);
|
||||||
observer.onWindowUpdateRead(ctx, streamId, windowSizeIncrement);
|
listener.onWindowUpdateRead(ctx, streamId, windowSizeIncrement);
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUnknownFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags,
|
public void onUnknownFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags,
|
||||||
ByteBuf payload) {
|
ByteBuf payload) {
|
||||||
observer.onUnknownFrame(ctx, frameType, streamId, flags, payload);
|
listener.onUnknownFrame(ctx, frameType, streamId, flags, payload);
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user