docker/docker — pull request #9652 by yadutaf (2014-12-13 13:32:56+00:00)
Title: Set HTTP upgrade headers when hijacking connection

When setting up a reverse proxy like Nginx behind Docker client and Docker remote API most commands works fine except `docker attach` and `docker exec`. When these commands are used, docker "hijacks" the HTTP connection back to raw bi-directional TCP. As the reverse proxy was expecting plain HTTP it is completely lost.

This Pull Request adds `Connection: Upgrade` and `Upgrade: tcp` HTTP headers as well as return code of `101 UPGRADED` in this scenario. It is fully backward compatible and, while 'tcp' upgrade is not standard, it is enough to trigger Nginx connection upgrade path as used by websockets.