IIS 7.5: Force Keep Alive header in Response

时光总嘲笑我的痴心妄想 提交于 2019-12-21 10:48:21

问题


Based on my research, IIS 7.5 doesn't include the Connection:Keep-Alive in its response for reasons described here. Unfortunately, I have a non conforming client connecting to my web service that won't reuse sockets unless it sees Connection:Keep-Alive in the response header. I've tried programmatically adding this header but IIS appears to purposely strip it out. Is there any other way that I can force this header to be sent back to my naughty client?


回答1:


I opened a support ticket with Microsoft on this and had my worst suspicions confirmed. IIS 7.5 deliberately prevents the connection:keep-alive header from being returned in the response. Per the HTTP 1.1 RFC, all connections should assume keep alive (a departure from HTTP 1.0). Therefore, the omission of this header is the default and correct (?) behavior. When keep-alives are not desirable, IIS will send the connection:close header.

What really surprised me is the great lengths to which IIS will go to to prevent this header from being sent. Something within the IIS pipeline strips out this header no matter how it is added. (C# code in my MVC application, IIS Manager-->HTTP Response Headers,IIS Manager-->URL Rewrite Module).

You would think MS would allow some sort of escape valve on this, given that there are so many non-conforming HTTP 1.1 clients in the wild that simply will not behave unless they see this header.



来源:https://stackoverflow.com/questions/19819622/iis-7-5-force-keep-alive-header-in-response

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!