Skip to content
New issue

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

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

Already on GitHub? Sign in 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

@carl-mastrangelo carl-mastrangelo commented Jan 20, 2021

No description provided.

private long seenContentLength;

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

@artgon artgon Jan 20, 2021

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

@carl-mastrangelo carl-mastrangelo Jan 20, 2021

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.

artgon
artgon approved these changes Jan 20, 2021
}
if (msg instanceof HttpContent) {
ByteBuf content = ((HttpContent) msg).content();
seenContentLength = Math.addExact(seenContentLength, content.readableBytes());
Copy link
Collaborator

@argha-c argha-c Jan 20, 2021

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

@carl-mastrangelo carl-mastrangelo Jan 20, 2021

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

@argha-c argha-c Jan 20, 2021

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

@carl-mastrangelo carl-mastrangelo Jan 20, 2021

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
2 checks passed
@carl-mastrangelo carl-mastrangelo deleted the sizeenf branch Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants