Remove duplicate HTTP2 payload length check against max frame size
Motivation: In the method processHeaderState(), we have checked the http2 payload length against max frame size. But later for different types of frames, we checked this again. Modifications: Removed the duplicate check in verify*() methods. And removed verifyPayloadLength() method, since it will not be used anymore. Result: Remove duplicate check and make the code cleaner.
This commit is contained in:
parent
0fdf2e7f3a
commit
120fb6fcdf
@ -283,7 +283,6 @@ public class DefaultHttp2FrameReader implements Http2FrameReader, Http2FrameSize
|
||||
private void verifyDataFrame() throws Http2Exception {
|
||||
verifyAssociatedWithAStream();
|
||||
verifyNotProcessingHeaders();
|
||||
verifyPayloadLength(payloadLength);
|
||||
|
||||
if (payloadLength < flags.getPaddingPresenceFieldLength()) {
|
||||
throw streamError(streamId, FRAME_SIZE_ERROR,
|
||||
@ -294,7 +293,6 @@ public class DefaultHttp2FrameReader implements Http2FrameReader, Http2FrameSize
|
||||
private void verifyHeadersFrame() throws Http2Exception {
|
||||
verifyAssociatedWithAStream();
|
||||
verifyNotProcessingHeaders();
|
||||
verifyPayloadLength(payloadLength);
|
||||
|
||||
int requiredLength = flags.getPaddingPresenceFieldLength() + flags.getNumPriorityBytes();
|
||||
if (payloadLength < requiredLength) {
|
||||
@ -324,7 +322,6 @@ public class DefaultHttp2FrameReader implements Http2FrameReader, Http2FrameSize
|
||||
|
||||
private void verifySettingsFrame() throws Http2Exception {
|
||||
verifyNotProcessingHeaders();
|
||||
verifyPayloadLength(payloadLength);
|
||||
if (streamId != 0) {
|
||||
throw connectionError(PROTOCOL_ERROR, "A stream ID must be zero.");
|
||||
}
|
||||
@ -338,7 +335,6 @@ public class DefaultHttp2FrameReader implements Http2FrameReader, Http2FrameSize
|
||||
|
||||
private void verifyPushPromiseFrame() throws Http2Exception {
|
||||
verifyNotProcessingHeaders();
|
||||
verifyPayloadLength(payloadLength);
|
||||
|
||||
// Subtract the length of the promised stream ID field, to determine the length of the
|
||||
// rest of the payload (header block fragment + payload).
|
||||
@ -362,7 +358,6 @@ public class DefaultHttp2FrameReader implements Http2FrameReader, Http2FrameSize
|
||||
|
||||
private void verifyGoAwayFrame() throws Http2Exception {
|
||||
verifyNotProcessingHeaders();
|
||||
verifyPayloadLength(payloadLength);
|
||||
|
||||
if (streamId != 0) {
|
||||
throw connectionError(PROTOCOL_ERROR, "A stream ID must be zero.");
|
||||
@ -383,7 +378,6 @@ public class DefaultHttp2FrameReader implements Http2FrameReader, Http2FrameSize
|
||||
|
||||
private void verifyContinuationFrame() throws Http2Exception {
|
||||
verifyAssociatedWithAStream();
|
||||
verifyPayloadLength(payloadLength);
|
||||
|
||||
if (headersContinuation == null) {
|
||||
throw connectionError(PROTOCOL_ERROR, "Received %s frame but not currently processing headers.",
|
||||
@ -767,12 +761,6 @@ public class DefaultHttp2FrameReader implements Http2FrameReader, Http2FrameSize
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyPayloadLength(int payloadLength) throws Http2Exception {
|
||||
if (payloadLength > maxFrameSize) {
|
||||
throw connectionError(PROTOCOL_ERROR, "Total payload length %d exceeds max frame length.", payloadLength);
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyAssociatedWithAStream() throws Http2Exception {
|
||||
if (streamId == 0) {
|
||||
throw connectionError(PROTOCOL_ERROR, "Frame of type %s must be associated with a stream.", frameType);
|
||||
|
Loading…
Reference in New Issue
Block a user