1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.handler.codec.http2;
17
18
19
20
21 public final class DefaultHttp2PushPromiseFrame implements Http2PushPromiseFrame {
22
23 private Http2FrameStream pushStreamFrame;
24 private final Http2Headers http2Headers;
25 private Http2FrameStream streamFrame;
26 private final int padding;
27 private final int promisedStreamId;
28
29 public DefaultHttp2PushPromiseFrame(Http2Headers http2Headers) {
30 this(http2Headers, 0);
31 }
32
33 public DefaultHttp2PushPromiseFrame(Http2Headers http2Headers, int padding) {
34 this(http2Headers, padding, -1);
35 }
36
37 DefaultHttp2PushPromiseFrame(Http2Headers http2Headers, int padding, int promisedStreamId) {
38 this.http2Headers = http2Headers;
39 this.padding = padding;
40 this.promisedStreamId = promisedStreamId;
41 }
42
43 @Override
44 public Http2StreamFrame pushStream(Http2FrameStream stream) {
45 pushStreamFrame = stream;
46 return this;
47 }
48
49 @Override
50 public Http2FrameStream pushStream() {
51 return pushStreamFrame;
52 }
53
54 @Override
55 public Http2Headers http2Headers() {
56 return http2Headers;
57 }
58
59 @Override
60 public int padding() {
61 return padding;
62 }
63
64 @Override
65 public int promisedStreamId() {
66 if (pushStreamFrame != null) {
67 return pushStreamFrame.id();
68 } else {
69 return promisedStreamId;
70 }
71 }
72
73 @Override
74 public Http2PushPromiseFrame stream(Http2FrameStream stream) {
75 streamFrame = stream;
76 return this;
77 }
78
79 @Override
80 public Http2FrameStream stream() {
81 return streamFrame;
82 }
83
84 @Override
85 public String name() {
86 return "PUSH_PROMISE_FRAME";
87 }
88
89 @Override
90 public String toString() {
91 return "DefaultHttp2PushPromiseFrame{" +
92 "pushStreamFrame=" + pushStreamFrame +
93 ", http2Headers=" + http2Headers +
94 ", streamFrame=" + streamFrame +
95 ", padding=" + padding +
96 '}';
97 }
98 }