1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.handler.codec.spdy;
17
18 import io.netty.util.internal.StringUtil;
19
20 import java.util.Map;
21
22
23
24
25 public class DefaultSpdyHeadersFrame extends DefaultSpdyStreamFrame
26 implements SpdyHeadersFrame {
27
28 private boolean invalid;
29 private boolean truncated;
30 private final SpdyHeaders headers = new DefaultSpdyHeaders();
31
32
33
34
35
36
37 public DefaultSpdyHeadersFrame(int streamId) {
38 super(streamId);
39 }
40
41 @Override
42 public SpdyHeadersFrame setStreamId(int streamId) {
43 super.setStreamId(streamId);
44 return this;
45 }
46
47 @Override
48 public SpdyHeadersFrame setLast(boolean last) {
49 super.setLast(last);
50 return this;
51 }
52
53 @Override
54 public boolean isInvalid() {
55 return invalid;
56 }
57
58 @Override
59 public SpdyHeadersFrame setInvalid() {
60 invalid = true;
61 return this;
62 }
63
64 @Override
65 public boolean isTruncated() {
66 return truncated;
67 }
68
69 @Override
70 public SpdyHeadersFrame setTruncated() {
71 truncated = true;
72 return this;
73 }
74
75 @Override
76 public SpdyHeaders headers() {
77 return headers;
78 }
79
80 @Override
81 public String toString() {
82 StringBuilder buf = new StringBuilder()
83 .append(StringUtil.simpleClassName(this))
84 .append("(last: ")
85 .append(isLast())
86 .append(')')
87 .append(StringUtil.NEWLINE)
88 .append("--> Stream-ID = ")
89 .append(streamId())
90 .append(StringUtil.NEWLINE)
91 .append("--> Headers:")
92 .append(StringUtil.NEWLINE);
93 appendHeaders(buf);
94
95
96 buf.setLength(buf.length() - StringUtil.NEWLINE.length());
97 return buf.toString();
98 }
99
100 protected void appendHeaders(StringBuilder buf) {
101 for (Map.Entry<String, String> e: headers()) {
102 buf.append(" ");
103 buf.append(e.getKey());
104 buf.append(": ");
105 buf.append(e.getValue());
106 buf.append(StringUtil.NEWLINE);
107 }
108 }
109 }