This repository was archived by the owner on Dec 18, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +4
-24
lines changed
src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http Expand file tree Collapse file tree 1 file changed +4
-24
lines changed Original file line number Diff line number Diff line change 7
7
using System . Linq ;
8
8
using Microsoft . AspNetCore . Http ;
9
9
using Microsoft . Extensions . Primitives ;
10
+ using Microsoft . Net . Http . Headers ;
10
11
11
12
namespace Microsoft . AspNetCore . Server . Kestrel . Internal . Http
12
13
{
@@ -234,31 +235,10 @@ public static void ValidateHeaderCharacters(string headerCharacters)
234
235
235
236
public static unsafe long ParseContentLength ( StringValues value )
236
237
{
237
- var input = value . ToString ( ) ;
238
- var parsed = 0L ;
239
-
240
- fixed ( char * ptr = input )
238
+ long parsed ;
239
+ if ( ! HeaderUtilities . TryParseInt64 ( new StringSegment ( value . ToString ( ) ) , out parsed ) )
241
240
{
242
- var ch = ( ushort * ) ptr ;
243
- var end = ch + input . Length ;
244
-
245
- if ( ch == end )
246
- {
247
- ThrowInvalidContentLengthException ( value ) ;
248
- }
249
-
250
- ushort digit = 0 ;
251
- while ( ch < end && ( digit = ( ushort ) ( * ch - 0x30 ) ) <= 9 )
252
- {
253
- parsed *= 10 ;
254
- parsed += digit ;
255
- ch ++ ;
256
- }
257
-
258
- if ( ch != end )
259
- {
260
- ThrowInvalidContentLengthException ( value ) ;
261
- }
241
+ ThrowInvalidContentLengthException ( value ) ;
262
242
}
263
243
264
244
return parsed ;
You can’t perform that action at this time.
0 commit comments