The attached patch creates a new field in r->headers_out called "connection". Modules could use this field to override the automatically generated Connection header in locally generated HTTP responses. This is needed to perform a HTTP connection upgrade, for example, in a WebSocket handshake.
Please consider including this patch in one of future releases of nginx. Thanks a lot!