-
Notifications
You must be signed in to change notification settings - Fork 524
Handle non "chunked" Transfer-Encoding header values (#1181) #1185
Conversation
No impact on plaintext benchmark: dev: 1210317.84 RPS |
For compression |
{ | ||
await connection.SendAll( | ||
"POST / HTTP/1.1", | ||
"Transfer-Encoding: not-chunked", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test where the request includes both a Content-Length
and a non-chunked Transfer-Encoding
?
@@ -812,6 +812,8 @@ private Task WriteSuffix() | |||
var responseHeaders = FrameResponseHeaders; | |||
var hasConnection = responseHeaders.HasConnection; | |||
var connectionOptions = hasConnection ? FrameHeaders.ParseConnection(responseHeaders.HeaderConnection) : ConnectionOptions.None; | |||
var hasTransferEncoding = responseHeaders.HasTransferEncoding; | |||
var transferCoding = hasTransferEncoding ? FrameHeaders.GetFinalTransferCoding(responseHeaders.HeaderTransferEncoding) : TransferCoding.None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: HasConnection and HasContentLength both simply call StringValues.Count. It would be simpler to have ParseConnection and GetFinalTransferCoding check the Count themselves and return None rather than doing the Has checks here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realized I don't even have to check Count
- the foreach
simply won't iterate over anything and those methods will return None
.
|
||
if (hasConnection) | ||
{ | ||
responseHeaders.SetRawConnection("close", _bytesConnectionClose); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like setting _keepAlive to false, but I'm not sure about changing headers that the user as already explicitly set even to save them from violating the HTTP spec. Do we do that for other headers?
Updated. |
be7ab02
to
7763bf3
Compare
Ping. |
|
7763bf3
to
2940895
Compare
#1181
chunked
is not final token inTransfer-Encoding
chunked
is not final token in responseTransfer-Encoding
Point for discussion: should we insert
chunked
and auto-chunk responses that don't havechunked
inTransfer-Encoding
? Or should we leave it up to the app to chunk the response in those cases? The problem with not auto-chunking is that Kestrel will now close the connection if such a response is sent.@halter73 @davidfowl @Tratcher @mikeharder