@@ -48,6 +48,151 @@ public void minResponseForCompressionPositive() {
48
48
assertThat (builder .build ().minCompressionResponseSize ()).isEqualTo (10 );
49
49
}
50
50
51
+ @ Test
52
+ public void httpCodecSizesModified () {
53
+ HttpServerOptions .Builder builder = HttpServerOptions .builder ();
54
+ builder .httpCodecOptions (123 , 456 , 789 );
55
+
56
+ assertThat (builder .build ().httpCodecMaxInitialLineLength ()).isEqualTo (123 );
57
+ assertThat (builder .build ().httpCodecMaxHeaderSize ()).isEqualTo (456 );
58
+ assertThat (builder .build ().httpCodecMaxChunkSize ()).isEqualTo (789 );
59
+ }
60
+
61
+ @ Test
62
+ public void httpCodecSizesDefaults () {
63
+ HttpServerOptions .Builder builder = HttpServerOptions .builder ();
64
+
65
+ assertThat (builder .build ().httpCodecMaxInitialLineLength ()).isEqualTo (4096 );
66
+ assertThat (builder .build ().httpCodecMaxHeaderSize ()).isEqualTo (8192 );
67
+ assertThat (builder .build ().httpCodecMaxChunkSize ()).isEqualTo (8192 );
68
+ }
69
+
70
+ @ Test
71
+ public void httpCodecSizesLineNegativeDefaults () {
72
+ HttpServerOptions .Builder builder = HttpServerOptions .builder ();
73
+ builder .httpCodecOptions (-1 , 456 , 789 );
74
+
75
+ assertThat (builder .build ().httpCodecMaxInitialLineLength ()).isEqualTo (4096 );
76
+ assertThat (builder .build ().httpCodecMaxHeaderSize ()).isEqualTo (456 );
77
+ assertThat (builder .build ().httpCodecMaxChunkSize ()).isEqualTo (789 );
78
+ }
79
+
80
+ @ Test
81
+ public void httpCodecSizesLineZeroDefaults () {
82
+ HttpServerOptions .Builder builder = HttpServerOptions .builder ();
83
+ builder .httpCodecOptions (0 , 456 , 789 );
84
+
85
+ assertThat (builder .build ().httpCodecMaxInitialLineLength ()).isEqualTo (4096 );
86
+ assertThat (builder .build ().httpCodecMaxHeaderSize ()).isEqualTo (456 );
87
+ assertThat (builder .build ().httpCodecMaxChunkSize ()).isEqualTo (789 );
88
+ }
89
+
90
+ @ Test
91
+ public void httpCodecSizesLineNegativeIgnored () {
92
+ HttpServerOptions .Builder builder = HttpServerOptions .builder ();
93
+ builder .httpCodecOptions (123 , 456 , 789 )
94
+ .httpCodecOptions (-1 , 1 , 2 );
95
+
96
+ assertThat (builder .build ().httpCodecMaxInitialLineLength ()).isEqualTo (123 );
97
+ assertThat (builder .build ().httpCodecMaxHeaderSize ()).isEqualTo (1 );
98
+ assertThat (builder .build ().httpCodecMaxChunkSize ()).isEqualTo (2 );
99
+ }
100
+
101
+ @ Test
102
+ public void httpCodecSizesLineZeroIgnored () {
103
+ HttpServerOptions .Builder builder = HttpServerOptions .builder ();
104
+ builder .httpCodecOptions (123 , 456 , 789 )
105
+ .httpCodecOptions (0 , 1 , 2 );
106
+
107
+ assertThat (builder .build ().httpCodecMaxInitialLineLength ()).isEqualTo (123 );
108
+ assertThat (builder .build ().httpCodecMaxHeaderSize ()).isEqualTo (1 );
109
+ assertThat (builder .build ().httpCodecMaxChunkSize ()).isEqualTo (2 );
110
+ }
111
+
112
+ @ Test
113
+ public void httpCodecSizesHeaderNegativeDefaults () {
114
+ HttpServerOptions .Builder builder = HttpServerOptions .builder ();
115
+ builder .httpCodecOptions (123 , -1 , 789 );
116
+
117
+ assertThat (builder .build ().httpCodecMaxInitialLineLength ()).isEqualTo (123 );
118
+ assertThat (builder .build ().httpCodecMaxHeaderSize ()).isEqualTo (8192 );
119
+ assertThat (builder .build ().httpCodecMaxChunkSize ()).isEqualTo (789 );
120
+ }
121
+
122
+ @ Test
123
+ public void httpCodecSizesHeaderZeroDefaults () {
124
+ HttpServerOptions .Builder builder = HttpServerOptions .builder ();
125
+ builder .httpCodecOptions (123 , 0 , 789 );
126
+
127
+ assertThat (builder .build ().httpCodecMaxInitialLineLength ()).isEqualTo (123 );
128
+ assertThat (builder .build ().httpCodecMaxHeaderSize ()).isEqualTo (8192 );
129
+ assertThat (builder .build ().httpCodecMaxChunkSize ()).isEqualTo (789 );
130
+ }
131
+
132
+ @ Test
133
+ public void httpCodecSizesHeaderNegativeIgnored () {
134
+ HttpServerOptions .Builder builder = HttpServerOptions .builder ();
135
+ builder .httpCodecOptions (123 , 456 , 789 )
136
+ .httpCodecOptions (1 , -1 , 2 );
137
+
138
+ assertThat (builder .build ().httpCodecMaxInitialLineLength ()).isEqualTo (1 );
139
+ assertThat (builder .build ().httpCodecMaxHeaderSize ()).isEqualTo (456 );
140
+ assertThat (builder .build ().httpCodecMaxChunkSize ()).isEqualTo (2 );
141
+ }
142
+
143
+ @ Test
144
+ public void httpCodecSizesHeaderZeroIgnored () {
145
+ HttpServerOptions .Builder builder = HttpServerOptions .builder ();
146
+ builder .httpCodecOptions (123 , 456 , 789 )
147
+ .httpCodecOptions (1 , 0 , 2 );
148
+
149
+ assertThat (builder .build ().httpCodecMaxInitialLineLength ()).isEqualTo (1 );
150
+ assertThat (builder .build ().httpCodecMaxHeaderSize ()).isEqualTo (456 );
151
+ assertThat (builder .build ().httpCodecMaxChunkSize ()).isEqualTo (2 );
152
+ }
153
+
154
+ @ Test
155
+ public void httpCodecSizesChunkNegativeDefaults () {
156
+ HttpServerOptions .Builder builder = HttpServerOptions .builder ();
157
+ builder .httpCodecOptions (123 , 456 , -1 );
158
+
159
+ assertThat (builder .build ().httpCodecMaxInitialLineLength ()).isEqualTo (123 );
160
+ assertThat (builder .build ().httpCodecMaxHeaderSize ()).isEqualTo (456 );
161
+ assertThat (builder .build ().httpCodecMaxChunkSize ()).isEqualTo (8192 );
162
+ }
163
+
164
+ @ Test
165
+ public void httpCodecSizesChunkZeroDefaults () {
166
+ HttpServerOptions .Builder builder = HttpServerOptions .builder ();
167
+ builder .httpCodecOptions (123 , 456 , 0 );
168
+
169
+ assertThat (builder .build ().httpCodecMaxInitialLineLength ()).isEqualTo (123 );
170
+ assertThat (builder .build ().httpCodecMaxHeaderSize ()).isEqualTo (456 );
171
+ assertThat (builder .build ().httpCodecMaxChunkSize ()).isEqualTo (8192 );
172
+ }
173
+
174
+ @ Test
175
+ public void httpCodecSizesChunkNegativeIgnored () {
176
+ HttpServerOptions .Builder builder = HttpServerOptions .builder ();
177
+ builder .httpCodecOptions (123 , 456 , 789 )
178
+ .httpCodecOptions (1 , 2 , -1 );
179
+
180
+ assertThat (builder .build ().httpCodecMaxInitialLineLength ()).isEqualTo (1 );
181
+ assertThat (builder .build ().httpCodecMaxHeaderSize ()).isEqualTo (2 );
182
+ assertThat (builder .build ().httpCodecMaxChunkSize ()).isEqualTo (789 );
183
+ }
184
+
185
+ @ Test
186
+ public void httpCodecSizesChunkZeroIgnored () {
187
+ HttpServerOptions .Builder builder = HttpServerOptions .builder ();
188
+ builder .httpCodecOptions (123 , 456 , 789 )
189
+ .httpCodecOptions (1 , 2 , 0 );
190
+
191
+ assertThat (builder .build ().httpCodecMaxInitialLineLength ()).isEqualTo (1 );
192
+ assertThat (builder .build ().httpCodecMaxHeaderSize ()).isEqualTo (2 );
193
+ assertThat (builder .build ().httpCodecMaxChunkSize ()).isEqualTo (789 );
194
+ }
195
+
51
196
@ Test
52
197
public void asSimpleString () {
53
198
HttpServerOptions .Builder builder = HttpServerOptions .builder ();
@@ -69,30 +214,62 @@ public void asSimpleString() {
69
214
}
70
215
71
216
@ Test
72
- public void asDetailedString () {
217
+ public void asDetailedStringAddressAndCompression () {
73
218
HttpServerOptions .Builder builder = HttpServerOptions .builder ();
74
219
75
220
assertThat (builder .build ().asDetailedString ())
76
221
.matches ("^address=(0\\ .0\\ .0\\ .0/0\\ .0\\ .0\\ .0:0|/0:0:0:0:0:0:0:1).*" )
77
- .endsWith (", minCompressionResponseSize=-1" );
222
+ .contains (", minCompressionResponseSize=-1" );
78
223
79
224
//address
80
225
builder .host ("foo" ).port (123 );
81
226
assertThat (builder .build ().asDetailedString ())
82
227
.startsWith ("address=foo:123" )
83
- .endsWith (", minCompressionResponseSize=-1" );
228
+ .contains (", minCompressionResponseSize=-1" );
84
229
85
230
//gzip
86
231
builder .compression (true );
87
232
assertThat (builder .build ().asDetailedString ())
88
233
.startsWith ("address=foo:123" )
89
- .endsWith (", minCompressionResponseSize=0" );
234
+ .contains (", minCompressionResponseSize=0" );
90
235
91
236
//gzip with threshold
92
237
builder .compression (534 );
93
238
assertThat (builder .build ().asDetailedString ())
94
239
.startsWith ("address=foo:123" )
95
- .endsWith (", minCompressionResponseSize=534" );
240
+ .endsWith (", minCompressionResponseSize=534, httpCodecSizes={initialLine=4096,header=8192,chunk=8192}" );
241
+ }
242
+
243
+ @ Test
244
+ public void asDetailedStringHttpCodecSizes () {
245
+ //defaults
246
+ assertThat (HttpServerOptions .builder ()
247
+ .build ().asDetailedString ())
248
+ .endsWith (", httpCodecSizes={initialLine=4096,header=8192,chunk=8192}" );
249
+
250
+ //changed line length
251
+ assertThat (HttpServerOptions .builder ()
252
+ .httpCodecOptions (123 , 0 , -1 )
253
+ .build ().asDetailedString ())
254
+ .endsWith (", httpCodecSizes={initialLine=123,header=8192,chunk=8192}" );
255
+
256
+ //changed header size
257
+ assertThat (HttpServerOptions .builder ()
258
+ .httpCodecOptions (0 , 123 , -1 )
259
+ .build ().asDetailedString ())
260
+ .endsWith (", httpCodecSizes={initialLine=4096,header=123,chunk=8192}" );
261
+
262
+ //changed chunk size
263
+ assertThat (HttpServerOptions .builder ()
264
+ .httpCodecOptions (0 , -1 , 123 )
265
+ .build ().asDetailedString ())
266
+ .endsWith (", httpCodecSizes={initialLine=4096,header=8192,chunk=123}" );
267
+
268
+ //changed all sizes
269
+ assertThat (HttpServerOptions .builder ()
270
+ .httpCodecOptions (123 , 456 , 789 )
271
+ .build ().asDetailedString ())
272
+ .endsWith (", httpCodecSizes={initialLine=123,header=456,chunk=789}" );
96
273
}
97
274
98
275
@ Test
@@ -101,10 +278,11 @@ public void toStringContainsAsDetailedString() {
101
278
.compression (534 )
102
279
.host ("google.com" )
103
280
.port (123 );
104
- assertThat (builder .build ().toString ())
281
+ HttpServerOptions options = builder .build ();
282
+ assertThat (options .toString ())
105
283
.startsWith ("HttpServerOptions{address=google.com" )
106
284
.contains (":123" )
107
- .endsWith (", minCompressionResponseSize=534}" );
285
+ .endsWith (", minCompressionResponseSize=534, httpCodecSizes={initialLine=4096,header=8192,chunk=8192} }" );
108
286
}
109
287
110
288
}
0 commit comments