Skip to content

Commit

Permalink
Add frameType method to Http2Frame.
Browse files Browse the repository at this point in the history
  • Loading branch information
He-Pin committed Apr 23, 2024
1 parent 7bbb859 commit 4eb6c7d
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 0 deletions.
Expand Up @@ -87,6 +87,11 @@ public DefaultHttp2DataFrame stream(Http2FrameStream stream) {
return this;
}

@Override
public byte frameType() {
return Http2FrameTypes.DATA;
}

@Override
public String name() {
return "DATA";
Expand Down
Expand Up @@ -83,6 +83,11 @@ public DefaultHttp2GoAwayFrame(long errorCode, ByteBuf content) {
this.lastStreamId = lastStreamId;
}

@Override
public byte frameType() {
return Http2FrameTypes.GO_AWAY;
}

@Override
public String name() {
return "GOAWAY";
Expand Down
Expand Up @@ -69,6 +69,11 @@ public DefaultHttp2HeadersFrame stream(Http2FrameStream stream) {
return this;
}

@Override
public byte frameType() {
return Http2FrameTypes.HEADERS;
}

@Override
public String name() {
return "HEADERS";
Expand Down
Expand Up @@ -42,6 +42,11 @@ public boolean ack() {
return ack;
}

@Override
public byte frameType() {
return Http2FrameTypes.PING;
}

@Override
public String name() {
return "PING";
Expand Down
Expand Up @@ -54,6 +54,11 @@ public DefaultHttp2PriorityFrame stream(Http2FrameStream stream) {
return this;
}

@Override
public byte frameType() {
return Http2FrameTypes.PRIORITY;
}

@Override
public String name() {
return "PRIORITY_FRAME";
Expand Down
Expand Up @@ -84,6 +84,11 @@ public Http2FrameStream stream() {
return streamFrame;
}

@Override
public byte frameType() {
return Http2FrameTypes.PUSH_PROMISE;
}

@Override
public String name() {
return "PUSH_PROMISE_FRAME";
Expand Down
Expand Up @@ -52,6 +52,11 @@ public DefaultHttp2ResetFrame stream(Http2FrameStream stream) {
return this;
}

@Override
public byte frameType() {
return Http2FrameTypes.RST_STREAM;
}

@Override
public String name() {
return "RST_STREAM";
Expand Down
Expand Up @@ -21,6 +21,12 @@
* The default {@link Http2SettingsAckFrame} implementation.
*/
final class DefaultHttp2SettingsAckFrame implements Http2SettingsAckFrame {

@Override
public byte frameType() {
return Http2FrameTypes.SETTINGS;
}

@Override
public String name() {
return "SETTINGS(ACK)";
Expand Down
Expand Up @@ -37,6 +37,11 @@ public Http2Settings settings() {
return settings;
}

@Override
public byte frameType() {
return Http2FrameTypes.SETTINGS;
}

@Override
public String name() {
return "SETTINGS";
Expand Down
Expand Up @@ -36,6 +36,11 @@ public DefaultHttp2WindowUpdateFrame stream(Http2FrameStream stream) {
return this;
}

@Override
public byte frameType() {
return Http2FrameTypes.WINDOW_UPDATE;
}

@Override
public String name() {
return "WINDOW_UPDATE";
Expand Down
Expand Up @@ -15,12 +15,20 @@
*/
package io.netty.handler.codec.http2;

import io.netty.util.NotImplementedYetException;
import io.netty.util.internal.UnstableApi;

/** An HTTP/2 frame. */
@UnstableApi
public interface Http2Frame {

/**
* Returns the type of the HTTP/2 frame e.g. DATA, GOAWAY, etc.
*/
default byte frameType() {
throw new NotImplementedYetException();
}

/**
* Returns the name of the HTTP/2 frame e.g. DATA, GOAWAY, etc.
*/
Expand Down
Expand Up @@ -28,6 +28,7 @@ public interface Http2UnknownFrame extends Http2StreamFrame, ByteBufHolder {
@Override
Http2UnknownFrame stream(Http2FrameStream stream);

@Override
byte frameType();

Http2Flags flags();
Expand Down
27 changes: 27 additions & 0 deletions common/src/main/java/io/netty/util/NotImplementedYetException.java
@@ -0,0 +1,27 @@
/*
* Copyright 2020 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

package io.netty.util;

public final class NotImplementedYetException extends RuntimeException {
public NotImplementedYetException(String message) {
super(message);
}

public NotImplementedYetException() {
super("Not implemented yet.");
}
}
6 changes: 6 additions & 0 deletions pom.xml
Expand Up @@ -1323,6 +1323,12 @@
<new>method io.netty.handler.codec.http2.Http2ConnectionHandlerBuilder io.netty.handler.codec.http2.Http2ConnectionHandlerBuilder::decoderEnforceMaxRstFramesPerWindow(int, int)</new>
<justification>Acceptable incompatibility for required change, because the method was not previously exposed; protected visiblity in super-class, not made public in final sub-class until now</justification>
</item>
<item>
<ignore>true</ignore>
<code>java.method.addedToInterface</code>
<new>method byte io.netty.handler.codec.http2.Http2Frame::frameType()</new>
<justification>Acceptable incompatibility for required change</justification>
</item>
</differences>
</revapi.differences>
</analysisConfiguration>
Expand Down

0 comments on commit 4eb6c7d

Please sign in to comment.