This repository was archived by the owner on Dec 18, 2018. It is now read-only.
File tree 1 file changed +9
-5
lines changed
src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -281,12 +281,16 @@ public static MessageBody For(
281
281
}
282
282
}
283
283
284
- // If we got here, request contains no Content-Length or Transfer-Encoding header.
285
- // Reject with 411 Length Required.
286
- if ( HttpMethods . IsPost ( context . Method ) || HttpMethods . IsPut ( context . Method ) )
284
+ // Avoid slowing down most common case
285
+ if ( ! object . ReferenceEquals ( context . Method , HttpMethods . Get ) )
287
286
{
288
- var requestRejectionReason = httpVersion == HttpVersion . Http11 ? RequestRejectionReason . LengthRequired : RequestRejectionReason . LengthRequiredHttp10 ;
289
- context . RejectRequest ( requestRejectionReason , context . Method ) ;
287
+ // If we got here, request contains no Content-Length or Transfer-Encoding header.
288
+ // Reject with 411 Length Required.
289
+ if ( HttpMethods . IsPost ( context . Method ) || HttpMethods . IsPut ( context . Method ) )
290
+ {
291
+ var requestRejectionReason = httpVersion == HttpVersion . Http11 ? RequestRejectionReason . LengthRequired : RequestRejectionReason . LengthRequiredHttp10 ;
292
+ context . RejectRequest ( requestRejectionReason , context . Method ) ;
293
+ }
290
294
}
291
295
292
296
return new ForContentLength ( keepAlive , 0 , context ) ;
You can’t perform that action at this time.
0 commit comments