1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.handler.codec.http;
17
18 import static io.netty.util.internal.ObjectUtil.checkNotNull;
19 import static io.netty.util.internal.ObjectUtil.checkPositive;
20
21
22
23
24
25
26
27 public final class HttpDecoderConfig implements Cloneable {
28 private int maxChunkSize = HttpObjectDecoder.DEFAULT_MAX_CHUNK_SIZE;
29 private boolean chunkedSupported = HttpObjectDecoder.DEFAULT_CHUNKED_SUPPORTED;
30 private boolean allowPartialChunks = HttpObjectDecoder.DEFAULT_ALLOW_PARTIAL_CHUNKS;
31 private HttpHeadersFactory headersFactory = DefaultHttpHeadersFactory.headersFactory();
32 private HttpHeadersFactory trailersFactory = DefaultHttpHeadersFactory.trailersFactory();
33 private boolean allowDuplicateContentLengths = HttpObjectDecoder.DEFAULT_ALLOW_DUPLICATE_CONTENT_LENGTHS;
34 private int maxInitialLineLength = HttpObjectDecoder.DEFAULT_MAX_INITIAL_LINE_LENGTH;
35 private int maxHeaderSize = HttpObjectDecoder.DEFAULT_MAX_HEADER_SIZE;
36 private int initialBufferSize = HttpObjectDecoder.DEFAULT_INITIAL_BUFFER_SIZE;
37
38 public int getInitialBufferSize() {
39 return initialBufferSize;
40 }
41
42
43
44
45
46
47
48 public HttpDecoderConfig setInitialBufferSize(int initialBufferSize) {
49 checkPositive(initialBufferSize, "initialBufferSize");
50 this.initialBufferSize = initialBufferSize;
51 return this;
52 }
53
54 public int getMaxInitialLineLength() {
55 return maxInitialLineLength;
56 }
57
58
59
60
61
62
63
64
65
66 public HttpDecoderConfig setMaxInitialLineLength(int maxInitialLineLength) {
67 checkPositive(maxInitialLineLength, "maxInitialLineLength");
68 this.maxInitialLineLength = maxInitialLineLength;
69 return this;
70 }
71
72 public int getMaxHeaderSize() {
73 return maxHeaderSize;
74 }
75
76
77
78
79
80
81
82
83
84 public HttpDecoderConfig setMaxHeaderSize(int maxHeaderSize) {
85 checkPositive(maxHeaderSize, "maxHeaderSize");
86 this.maxHeaderSize = maxHeaderSize;
87 return this;
88 }
89
90 public int getMaxChunkSize() {
91 return maxChunkSize;
92 }
93
94
95
96
97
98
99
100
101
102
103 public HttpDecoderConfig setMaxChunkSize(int maxChunkSize) {
104 checkPositive(maxChunkSize, "maxChunkSize");
105 this.maxChunkSize = maxChunkSize;
106 return this;
107 }
108
109 public boolean isChunkedSupported() {
110 return chunkedSupported;
111 }
112
113
114
115
116
117
118
119
120 public HttpDecoderConfig setChunkedSupported(boolean chunkedSupported) {
121 this.chunkedSupported = chunkedSupported;
122 return this;
123 }
124
125 public boolean isAllowPartialChunks() {
126 return allowPartialChunks;
127 }
128
129
130
131
132
133
134
135 public HttpDecoderConfig setAllowPartialChunks(boolean allowPartialChunks) {
136 this.allowPartialChunks = allowPartialChunks;
137 return this;
138 }
139
140 public HttpHeadersFactory getHeadersFactory() {
141 return headersFactory;
142 }
143
144
145
146
147
148
149
150
151
152
153
154 public HttpDecoderConfig setHeadersFactory(HttpHeadersFactory headersFactory) {
155 checkNotNull(headersFactory, "headersFactory");
156 this.headersFactory = headersFactory;
157 return this;
158 }
159
160 public boolean isAllowDuplicateContentLengths() {
161 return allowDuplicateContentLengths;
162 }
163
164
165
166
167
168
169
170
171
172 public HttpDecoderConfig setAllowDuplicateContentLengths(boolean allowDuplicateContentLengths) {
173 this.allowDuplicateContentLengths = allowDuplicateContentLengths;
174 return this;
175 }
176
177
178
179
180
181
182
183
184
185
186
187
188 public HttpDecoderConfig setValidateHeaders(boolean validateHeaders) {
189 DefaultHttpHeadersFactory noValidation = DefaultHttpHeadersFactory.headersFactory().withValidation(false);
190 headersFactory = validateHeaders ? DefaultHttpHeadersFactory.headersFactory() : noValidation;
191 trailersFactory = validateHeaders ? DefaultHttpHeadersFactory.trailersFactory() : noValidation;
192 return this;
193 }
194
195 public HttpHeadersFactory getTrailersFactory() {
196 return trailersFactory;
197 }
198
199
200
201
202
203
204
205
206
207
208
209
210
211 public HttpDecoderConfig setTrailersFactory(HttpHeadersFactory trailersFactory) {
212 checkNotNull(trailersFactory, "trailersFactory");
213 this.trailersFactory = trailersFactory;
214 return this;
215 }
216
217 @Override
218 public HttpDecoderConfig clone() {
219 try {
220 return (HttpDecoderConfig) super.clone();
221 } catch (CloneNotSupportedException e) {
222 throw new AssertionError();
223 }
224 }
225 }