You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.
I believe that Kestrel sets the Connection: close header in response to non keep-alive HTTP/1.1 requests in lieu of Content-Length: 0.
Looking into this, I think the behavior is somewhat broken for HTTP/1.0 requests post #835. We don't send the Connection: close response header in response to HTTP/1.0 requests. Omitting the header made a bit a sense when Kestrel would send HTTP/1.0 responses since Connection: close is implicit in that case, but now that all responses are HTTP/1.1 we should probably send the headers regardless.
I just submitted a PR (#1043) so that we send the Connection: close header in response to HTTP/1.0 request. Does this resolve your issue @tmds? Or is there some reason Content-Length: 0 should also be set even though the connection is being immediately closed?
I think the behavior is okay and consider sending Content-Length zero in this case an improvement.
The RFC has the following on this:
14.13 Content-Length
...
Applications SHOULD use this field to indicate the transfer-length of
the message-body, unless this is prohibited by the rules in section
4.4.
...
It may be beneficial to whomever is parsing the request to know how many bytes will follow before the close.
@tmds We are changing the behavior as you suggested.
In 1.1.0, Kestrel will automatically set both the Connection: close and Content-Length: 0 headers when the app doesn't write to the response body of a non keep-alive request. Assuming the the app hasn't changed either of those headers itself of course.
Content-Length is set to zero when an AppFunc completes without a write, see #174.
This doesn't happen when the connection isn't persistent (
_keepAlive == false
).When using Kestrel with IIS, IIS adds
Content-Length: 0
.The text was updated successfully, but these errors were encountered: