The Agent classes of http and https both have a createConnection() method which can be used to overwrite socket creation. http even supports createConnection as an option in request(). http2 does not support this part of the API and does not mention this difference in the API documentation.
It seems that implementing this for plain connections in http2 seems quite straight forward, but I have not fully understood the creation of connections for SSL in this library, yet.
PS: One use case for this is to tunnel the request through something like a VPN or SSH port forwarding by returning a socket-like object in createConnection
The Agent classes of
httpandhttpsboth have acreateConnection()method which can be used to overwrite socket creation.httpeven supportscreateConnectionas an option inrequest().http2does not support this part of the API and does not mention this difference in the API documentation.It seems that implementing this for
plainconnections inhttp2seems quite straight forward, but I have not fully understood the creation of connections for SSL in this library, yet.PS: One use case for this is to tunnel the request through something like a VPN or SSH port forwarding by returning a socket-like object in
createConnection