Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

core: add checks to chunked encoding for http/2 #980

Merged
merged 4 commits into from
Jan 20, 2021

Conversation

carl-mastrangelo
Copy link
Contributor

No description provided.

private long seenContentLength;

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be useful to add a comment for each type of violation that you're checking against.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment block at the top.

}
if (msg instanceof HttpContent) {
ByteBuf content = ((HttpContent) msg).content();
seenContentLength = Math.addExact(seenContentLength, content.readableBytes());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest extracting this into a method, for readability. It's stateful and the increment isn't obvious immediately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

return;
}
}
if (expectedContentLength != UNSET_CONTENT_LENGTH && HttpUtil.isTransferEncodingChunked(req)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider extracting usages of expectedContentLength != UNSET_CONTENT_LENGTH and naming appropriately to convey the intent of that check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@carl-mastrangelo carl-mastrangelo merged commit 12b62a9 into Netflix:master Jan 20, 2021
@carl-mastrangelo carl-mastrangelo deleted the sizeenf branch January 20, 2021 23:04
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants