File tree 1 file changed +5
-9
lines changed
src/Servers/Kestrel/Core/src/Internal/Http
1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -280,16 +280,12 @@ public static MessageBody For(
280
280
return new ForContentLength ( keepAlive , contentLength , context ) ;
281
281
}
282
282
283
- // Avoid slowing down most common case
284
- if ( ! object . ReferenceEquals ( context . Method , HttpMethods . Get ) )
283
+ // If we got here, request contains no Content-Length or Transfer-Encoding header.
284
+ // Reject with 411 Length Required.
285
+ if ( context . Method == HttpMethod . Post || context . Method == HttpMethod . Put )
285
286
{
286
- // If we got here, request contains no Content-Length or Transfer-Encoding header.
287
- // Reject with 411 Length Required.
288
- if ( context . Method == HttpMethod . Post || context . Method == HttpMethod . Put )
289
- {
290
- var requestRejectionReason = httpVersion == HttpVersion . Http11 ? RequestRejectionReason . LengthRequired : RequestRejectionReason . LengthRequiredHttp10 ;
291
- BadHttpRequestException . Throw ( requestRejectionReason , context . Method ) ;
292
- }
287
+ var requestRejectionReason = httpVersion == HttpVersion . Http11 ? RequestRejectionReason . LengthRequired : RequestRejectionReason . LengthRequiredHttp10 ;
288
+ BadHttpRequestException . Throw ( requestRejectionReason , context . Method ) ;
293
289
}
294
290
295
291
return keepAlive ? MessageBody . ZeroContentLengthKeepAlive : MessageBody . ZeroContentLengthClose ;
You can’t perform that action at this time.
0 commit comments