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 io.netty.util.internal.StringUtil;
19
20 import static io.netty.handler.codec.http2.Http2CodecUtil.verifyPadding;
21 import static io.netty.util.internal.ObjectUtil.checkNotNull;
22
23
24
25
26 public final class DefaultHttp2HeadersFrame extends AbstractHttp2StreamFrame implements Http2HeadersFrame {
27 private final Http2Headers headers;
28 private final boolean endStream;
29 private final int padding;
30
31
32
33
34
35
36 public DefaultHttp2HeadersFrame(Http2Headers headers) {
37 this(headers, false);
38 }
39
40
41
42
43
44
45 public DefaultHttp2HeadersFrame(Http2Headers headers, boolean endStream) {
46 this(headers, endStream, 0);
47 }
48
49
50
51
52
53
54
55
56
57 public DefaultHttp2HeadersFrame(Http2Headers headers, boolean endStream, int padding) {
58 this.headers = checkNotNull(headers, "headers");
59 this.endStream = endStream;
60 verifyPadding(padding);
61 this.padding = padding;
62 }
63
64 @Override
65 public DefaultHttp2HeadersFrame stream(Http2FrameStream stream) {
66 super.stream(stream);
67 return this;
68 }
69
70 @Override
71 public String name() {
72 return "HEADERS";
73 }
74
75 @Override
76 public Http2Headers headers() {
77 return headers;
78 }
79
80 @Override
81 public boolean isEndStream() {
82 return endStream;
83 }
84
85 @Override
86 public int padding() {
87 return padding;
88 }
89
90 @Override
91 public String toString() {
92 return StringUtil.simpleClassName(this) + "(stream=" + stream() + ", headers=" + headers
93 + ", endStream=" + endStream + ", padding=" + padding + ')';
94 }
95
96 @Override
97 public boolean equals(Object o) {
98 if (!(o instanceof DefaultHttp2HeadersFrame)) {
99 return false;
100 }
101 DefaultHttp2HeadersFrame other = (DefaultHttp2HeadersFrame) o;
102 return super.equals(other) && headers.equals(other.headers)
103 && endStream == other.endStream && padding == other.padding;
104 }
105
106 @Override
107 public int hashCode() {
108 int hash = super.hashCode();
109 hash = hash * 31 + headers.hashCode();
110 hash = hash * 31 + (endStream ? 0 : 1);
111 hash = hash * 31 + padding;
112 return hash;
113 }
114 }