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