private function tunnelThroughProxy(Deferred $promisor, $socket, $authority)
{
if (empty(stream_context_get_options($socket)['artax*']['is_tunneled'])) {
$futureTunnel = $this->tunneler->tunnel($socket, $authority);
$futureTunnel->when(function ($error) use($promisor, $socket) {
if ($error) {
$promisor->fail($error);
} else {
$promisor->succeed($socket);
}
});
} else {
$promisor->succeed($socket);
}
}