File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
src/Mvc/Mvc.Core/src/Formatters Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 11// Licensed to the .NET Foundation under one or more agreements.
22// The .NET Foundation licenses this file to you under the MIT license.
33
4+ using Microsoft . AspNetCore . Http . Features ;
45using Microsoft . AspNetCore . Mvc . ApiExplorer ;
56using Microsoft . AspNetCore . Mvc . Core ;
67
@@ -98,8 +99,11 @@ public virtual Task<InputFormatterResult> ReadAsync(InputFormatterContext contex
9899 throw new ArgumentNullException ( nameof ( context ) ) ;
99100 }
100101
101- var request = context . HttpContext . Request ;
102- if ( request . ContentLength == 0 )
102+ var hasBody = context . HttpContext . Features . Get < IHttpRequestBodyDetectionFeature > ( ) ? . CanHaveBody ;
103+ // In case the feature is not registered
104+ hasBody ??= context . HttpContext . Request . ContentLength is not null && context . HttpContext . Request . ContentLength != 0 ;
105+
106+ if ( hasBody == false )
103107 {
104108 if ( context . TreatEmptyInputAsDefaultValue )
105109 {
You can’t perform that action at this time.
0 commit comments