protected function getContextOptions($all = false)
    {
        if ($this->contextOptions === null) {
            $this->contextOptions   = stream_context_get_options($this->context);
        }

        if (!$all && array_key_exists(self::$protocol, $this->contextOptions)) {
            return $this->contextOptions[self::$protocol];
        } else if ($all) {
            return $this->contextOptions;
        } else {
            return array();
        }
    }