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.UnstableApi;
19
20
21
22
23 @UnstableApi
24 public final class DefaultHttp2PushPromiseFrame implements Http2PushPromiseFrame {
25
26 private Http2FrameStream pushStreamFrame;
27 private final Http2Headers http2Headers;
28 private Http2FrameStream streamFrame;
29 private final int padding;
30 private final int promisedStreamId;
31
32 public DefaultHttp2PushPromiseFrame(Http2Headers http2Headers) {
33 this(http2Headers, 0);
34 }
35
36 public DefaultHttp2PushPromiseFrame(Http2Headers http2Headers, int padding) {
37 this(http2Headers, padding, -1);
38 }
39
40 DefaultHttp2PushPromiseFrame(Http2Headers http2Headers, int padding, int promisedStreamId) {
41 this.http2Headers = http2Headers;
42 this.padding = padding;
43 this.promisedStreamId = promisedStreamId;
44 }
45
46 @Override
47 public Http2StreamFrame pushStream(Http2FrameStream stream) {
48 pushStreamFrame = stream;
49 return this;
50 }
51
52 @Override
53 public Http2FrameStream pushStream() {
54 return pushStreamFrame;
55 }
56
57 @Override
58 public Http2Headers http2Headers() {
59 return http2Headers;
60 }
61
62 @Override
63 public int padding() {
64 return padding;
65 }
66
67 @Override
68 public int promisedStreamId() {
69 if (pushStreamFrame != null) {
70 return pushStreamFrame.id();
71 } else {
72 return promisedStreamId;
73 }
74 }
75
76 @Override
77 public Http2PushPromiseFrame stream(Http2FrameStream stream) {
78 streamFrame = stream;
79 return this;
80 }
81
82 @Override
83 public Http2FrameStream stream() {
84 return streamFrame;
85 }
86
87 @Override
88 public String name() {
89 return "PUSH_PROMISE_FRAME";
90 }
91
92 @Override
93 public String toString() {
94 return "DefaultHttp2PushPromiseFrame{" +
95 "pushStreamFrame=" + pushStreamFrame +
96 ", http2Headers=" + http2Headers +
97 ", streamFrame=" + streamFrame +
98 ", padding=" + padding +
99 '}';
100 }
101 }