public function getConnection(
        $method,
        $path,
        $data = null,
        array $headers = []
    ) {
        $fullPath = $path;
        if ($this->options['path']) {
            $fullPath = '/'.$this->options['path'].$path;
        }

        $this->checkConnection();
        $stringHeader = $this->buildRequest($method, $fullPath, $data, $headers);
        // Send the build request to the server
        if (fwrite($this->connection, $stringHeader) === false) {
            // Reestablish which seems to have been aborted
            //
            // The recursion in this method might be problematic if the
            // connection establishing mechanism does not correctly throw an
            // exception on failure.
            $this->connection = null;

            return $this->getConnection($method, $path, $data, $headers);
        }

        return $this->connection;
    }