protected function execute(array $data) {
        // Auto-connect:
        if ($this->isConnected() === false) {
            $this->connect();
        }

        $this->lastRequestContent = $data;

        $dataAsString = json_encode($data);

        $options = $this->options;

        $options[CURLOPT_POSTFIELDS] = $dataAsString;

        if (isset($this->session)) {
            $options[CURLOPT_HTTPHEADER][] = 'X-RPC-Auth-Session: ' . $this->session;
        } elseif (array_key_exists(self::USERNAME, $this->config) &&
            is_string($this->config[self::USERNAME]) &&
            !empty($this->config[self::USERNAME]) &&
            array_key_exists(self::PASSWORD, $this->config) &&
            is_string($this->config[self::PASSWORD]) &&
            !empty($this->config[self::PASSWORD])) {
            $options[CURLOPT_HTTPHEADER][] = 'X-RPC-Auth-Username: ' . $this->config[self::USERNAME];
            $options[CURLOPT_HTTPHEADER][] = 'X-RPC-Auth-Password: ' . $this->config[self::PASSWORD];
        }

        curl_setopt_array($this->resource, $options);

        $responseString = curl_exec($this->resource);

        $this->lastInfo = curl_getinfo($this->resource);

        if ($responseString === false) {
            switch ($this->lastInfo['http_code']) {
                case 0:
                    $message = curl_error($this->resource);

                    if (strlen($message) === 0) {
                        $message = 'Connection to Web server failed';
                    }

                    throw new RuntimeException($message);
                default:
                    throw new RuntimeException(sprintf(
                        'Web server responded with HTTP status code "%s"',
                        $this->lastInfo['http_code']
                    ));
            }
        } elseif (!is_string($responseString)) {
            throw new RuntimeException('No content from Web server');
        }

        $headerLength = curl_getinfo($this->resource, CURLINFO_HEADER_SIZE);
        $this->lastResponseHeaders = substr($responseString, 0, $headerLength);

        $body = substr($responseString, $headerLength);

        $lastResponse = json_decode(trim($body), true);

        if (!is_array($lastResponse)) {
            if (is_string($body) && strlen($body) > 0) {
                throw new RuntimeException(sprintf(
                    'i-doit responded with an unknown message: %s',
                    $body
                ));
            } else {
                throw new RuntimeException('i-doit responded with an invalid JSON string.');
            }
        }

        $this->lastResponse = $lastResponse;

        return $this->lastResponse;
    }