HTTP Connect
To ensure that sensitive information is kept secret from potential eavesdroppers, TCP/IP includes secure protocols (SSL/TLS) which have been designed specifically to achieve true end-to-end security. These protocols work by following a handshake algorithm to establish a shared encryption key which is known only to the client and the secure server. Once the handshake is complete, all subsequent data transfer between the client and server are encrypted. Since the client and secure server are the only devices which know the shared encryption key, they alone are able to decrypt the communications using the shared encryption key.
A special case occurs when the client must use a proxy server to connect to a remote secure server. The proxy server must connect the client to the remote secure server so the handshake can take place to establish the shared encryption key. To maintain true end-to-end security, this encryption key must remain unknown to the proxy server .
To handle this special case, HTTP has a special method: CONNECT. This method is used by a client to instruct a proxy server to establish a connection with a remote server so that handshaking between the client and the remote server can take place. At the end of the handshake, the shared encryption key is established between the client and the remote secure server. All subsequent communications between the client and the remote secure server are encrypted using that key and sent to the proxy server which then acts only as a data relay between the client and the remote secure server. This is known as tunneling through the proxy. Since the proxy server does not know the encryption key, it cannot examine the data in the communications, and end-to-end security is preserved.
Socks proxying
Bill wishes to communicate with Jane over the internet, but a firewall between them exists on his network, where Bill is not authorized to communicate with Jane directly. So, Bill connects to the SOCKS proxy on his network, informing it about the connection he wishes to make to Jane; the SOCKS proxy opens a connection through the firewall and facilitates the communication between Bill and Jane.
Reference
https://devcentral.f5.com/articles/tunneling-with-http-connect
https://en.wikipedia.org/wiki/SOCKS