Skip to content

Commit

Permalink
HTTP/2 Read Decompression Flow Control Fix
Browse files Browse the repository at this point in the history
Motivation:
The current implementation of the HTTP/2 decompression does not integrate with flow control properly.
The decompression code is giving the post-decompression size to the flow control algorithm which
results in flow control errors at incorrect times.

Modifications:
-DecompressorHttp2FrameReader.java will need to change where it hooks into the HTTP/2 codec
-Enhance unit tests to test this condition

Result:
No more flow control errors because of decompression design flaw
  • Loading branch information
Scottmitch committed Sep 23, 2014
1 parent aba28d4 commit 3807f9f
Show file tree
Hide file tree
Showing 6 changed files with 393 additions and 283 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -367,23 +367,6 @@ private void verifyContinuationFrame() throws Http2Exception {
}
}

protected void notifyListenerOnDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data,
int padding, boolean endOfStream, Http2FrameListener listener) throws Http2Exception {
listener.onDataRead(ctx, streamId, data, padding, endOfStream);
}

protected void notifyListenerOnHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers,
int streamDependency, short weight, boolean exclusive, int padding,
boolean endOfStream, Http2FrameListener listener) throws Http2Exception {
listener.onHeadersRead(ctx, streamId, headers, streamDependency,
weight, exclusive, padding, endOfStream);
}

protected void notifyListenerOnHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers,
int padding, boolean endOfStream, Http2FrameListener listener) throws Http2Exception {
listener.onHeadersRead(ctx, streamId, headers, padding, endOfStream);
}

private void readDataFrame(ChannelHandlerContext ctx, ByteBuf payload,
Http2FrameListener listener) throws Http2Exception {
short padding = readPadding(payload);
Expand All @@ -396,7 +379,7 @@ private void readDataFrame(ChannelHandlerContext ctx, ByteBuf payload,
}

ByteBuf data = payload.readSlice(dataLength);
notifyListenerOnDataRead(ctx, streamId, data, padding, flags.endOfStream(), listener);
listener.onDataRead(ctx, streamId, data, padding, flags.endOfStream());
payload.skipBytes(payload.readableBytes());
}

Expand Down Expand Up @@ -428,8 +411,8 @@ public void processFragment(boolean endOfHeaders, ByteBuf fragment,
final HeadersBlockBuilder hdrBlockBuilder = headersBlockBuilder();
hdrBlockBuilder.addFragment(fragment, ctx.alloc(), endOfHeaders);
if (endOfHeaders) {
notifyListenerOnHeadersRead(ctx, headersStreamId, hdrBlockBuilder.headers(),
streamDependency, weight, exclusive, padding, headersFlags.endOfStream(), listener);
listener.onHeadersRead(ctx, headersStreamId, hdrBlockBuilder.headers(),
streamDependency, weight, exclusive, padding, headersFlags.endOfStream());
close();
}
}
Expand All @@ -454,8 +437,8 @@ public void processFragment(boolean endOfHeaders, ByteBuf fragment,
final HeadersBlockBuilder hdrBlockBuilder = headersBlockBuilder();
hdrBlockBuilder.addFragment(fragment, ctx.alloc(), endOfHeaders);
if (endOfHeaders) {
notifyListenerOnHeadersRead(ctx, headersStreamId, hdrBlockBuilder.headers(), padding,
headersFlags.endOfStream(), listener);
listener.onHeadersRead(ctx, headersStreamId, hdrBlockBuilder.headers(), padding,
headersFlags.endOfStream());
close();
}
}
Expand Down
Loading

0 comments on commit 3807f9f

Please sign in to comment.