1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.handler.codec.http2;
17
18 import static io.netty.util.internal.ObjectUtil.checkPositive;
19
20
21
22
23
24
25 final class Http2MaxRstFrameDecoder extends DecoratingHttp2ConnectionDecoder {
26 private final int maxRstFramesPerWindow;
27 private final int secondsPerWindow;
28
29 Http2MaxRstFrameDecoder(Http2ConnectionDecoder delegate, int maxRstFramesPerWindow, int secondsPerWindow) {
30 super(delegate);
31 this.maxRstFramesPerWindow = checkPositive(maxRstFramesPerWindow, "maxRstFramesPerWindow");
32 this.secondsPerWindow = checkPositive(secondsPerWindow, "secondsPerWindow");
33 }
34
35 @Override
36 public void frameListener(Http2FrameListener listener) {
37 if (listener != null) {
38 super.frameListener(new Http2MaxRstFrameListener(listener, maxRstFramesPerWindow, secondsPerWindow));
39 } else {
40 super.frameListener(null);
41 }
42 }
43
44 @Override
45 public Http2FrameListener frameListener() {
46 Http2FrameListener frameListener = frameListener0();
47
48 if (frameListener instanceof Http2MaxRstFrameListener) {
49 return ((Http2MaxRstFrameListener) frameListener).listener;
50 }
51 return frameListener;
52 }
53
54
55 Http2FrameListener frameListener0() {
56 return super.frameListener();
57 }
58 }