@@ -211,6 +211,28 @@ public void TryParseFormValues_Works(Encoding encoding)
211
211
Assert . Equal ( "" , dict [ "t" ] ) ;
212
212
}
213
213
214
+ [ Theory ]
215
+ [ MemberData ( nameof ( Encodings ) ) ]
216
+ public void TryParseFormValues_LimitsCanBeLarge ( Encoding encoding )
217
+ {
218
+ var readOnlySequence = ReadOnlySequenceFactory . SingleSegmentFactory . CreateWithContent ( encoding . GetBytes ( "foo=bar&baz=boo&t=" ) ) ;
219
+
220
+ KeyValueAccumulator accumulator = default ;
221
+
222
+ var formReader = new FormPipeReader ( null , encoding ) ;
223
+ formReader . KeyLengthLimit = int . MaxValue ;
224
+ formReader . ValueLengthLimit = int . MaxValue ;
225
+ formReader . ParseFormValues ( ref readOnlySequence , ref accumulator , isFinalBlock : false ) ;
226
+ formReader . ParseFormValues ( ref readOnlySequence , ref accumulator , isFinalBlock : true ) ;
227
+ Assert . True ( readOnlySequence . IsEmpty ) ;
228
+
229
+ Assert . Equal ( 3 , accumulator . KeyCount ) ;
230
+ var dict = accumulator . GetResults ( ) ;
231
+ Assert . Equal ( "bar" , dict [ "foo" ] ) ;
232
+ Assert . Equal ( "boo" , dict [ "baz" ] ) ;
233
+ Assert . Equal ( "" , dict [ "t" ] ) ;
234
+ }
235
+
214
236
[ Theory ]
215
237
[ MemberData ( nameof ( Encodings ) ) ]
216
238
public void TryParseFormValues_SplitAcrossSegmentsWorks ( Encoding encoding )
@@ -230,6 +252,28 @@ public void TryParseFormValues_SplitAcrossSegmentsWorks(Encoding encoding)
230
252
Assert . Equal ( "" , dict [ "t" ] ) ;
231
253
}
232
254
255
+ [ Theory ]
256
+ [ MemberData ( nameof ( Encodings ) ) ]
257
+ public void TryParseFormValues_SplitAcrossSegmentsWorks_LimitsCanBeLarge ( Encoding encoding )
258
+ {
259
+ var readOnlySequence = ReadOnlySequenceFactory . SegmentPerByteFactory . CreateWithContent ( encoding . GetBytes ( "foo=bar&baz=boo&t=" ) ) ;
260
+
261
+ KeyValueAccumulator accumulator = default ;
262
+
263
+ var formReader = new FormPipeReader ( null , encoding ) ;
264
+ formReader . KeyLengthLimit = int . MaxValue ;
265
+ formReader . ValueLengthLimit = int . MaxValue ;
266
+ formReader . ParseFormValues ( ref readOnlySequence , ref accumulator , isFinalBlock : false ) ;
267
+ formReader . ParseFormValues ( ref readOnlySequence , ref accumulator , isFinalBlock : true ) ;
268
+ Assert . True ( readOnlySequence . IsEmpty ) ;
269
+
270
+ Assert . Equal ( 3 , accumulator . KeyCount ) ;
271
+ var dict = accumulator . GetResults ( ) ;
272
+ Assert . Equal ( "bar" , dict [ "foo" ] ) ;
273
+ Assert . Equal ( "boo" , dict [ "baz" ] ) ;
274
+ Assert . Equal ( "" , dict [ "t" ] ) ;
275
+ }
276
+
233
277
[ Theory ]
234
278
[ MemberData ( nameof ( Encodings ) ) ]
235
279
public void TryParseFormValues_MultiSegmentWithArrayPoolAcrossSegmentsWorks ( Encoding encoding )
0 commit comments