1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jboss.netty.handler.codec.http;
17
18 import java.util.List;
19 import java.util.Map;
20 import java.util.Set;
21
22 import org.jboss.netty.buffer.ChannelBuffer;
23 import org.jboss.netty.buffer.ChannelBuffers;
24
25
26
27
28 public class DefaultHttpChunkTrailer implements HttpChunkTrailer {
29
30 private final HttpHeaders headers = new HttpHeaders() {
31 @Override
32 void validateHeaderName(String name) {
33 super.validateHeaderName(name);
34 if (name.equalsIgnoreCase(HttpHeaders.Names.CONTENT_LENGTH) ||
35 name.equalsIgnoreCase(HttpHeaders.Names.TRANSFER_ENCODING) ||
36 name.equalsIgnoreCase(HttpHeaders.Names.TRAILER)) {
37 throw new IllegalArgumentException(
38 "prohibited trailing header: " + name);
39 }
40 }
41 };
42
43 public boolean isLast() {
44 return true;
45 }
46
47 public void addHeader(final String name, final Object value) {
48 headers.addHeader(name, value);
49 }
50
51 public void setHeader(final String name, final Object value) {
52 headers.setHeader(name, value);
53 }
54
55 public void setHeader(final String name, final Iterable<?> values) {
56 headers.setHeader(name, values);
57 }
58
59 public void removeHeader(final String name) {
60 headers.removeHeader(name);
61 }
62
63 public void clearHeaders() {
64 headers.clearHeaders();
65 }
66
67 public String getHeader(final String name) {
68 return headers.getHeader(name);
69 }
70
71 public List<String> getHeaders(final String name) {
72 return headers.getHeaders(name);
73 }
74
75 public List<Map.Entry<String, String>> getHeaders() {
76 return headers.getHeaders();
77 }
78
79 public boolean containsHeader(final String name) {
80 return headers.containsHeader(name);
81 }
82
83 public Set<String> getHeaderNames() {
84 return headers.getHeaderNames();
85 }
86
87 public ChannelBuffer getContent() {
88 return ChannelBuffers.EMPTY_BUFFER;
89 }
90
91 public void setContent(ChannelBuffer content) {
92 throw new IllegalStateException("read-only");
93 }
94 }