public function getResponse(Settings $settings = null, $header = true, $return = false)
    {
        $callback = $this->getCallback();

        if ($header) {
            if (static::getCORSResponse()) {
                return null;
            }

            if ($callback) {
                header('Content-type: application/javascript');
            } else {
                header('Content-type: application/json');
            }
        }

        if (!$settings) {
            $settings = $this->getSettings();
        }
        $data = $this->getResponseObject($settings);

        $data['remote'] = [
            'url' => $settings->getFetchUrl(),
            'refreshAfter' => $this->refreshAfter
        ];
        $data['remote'][$settings->getFetchUrl()] = $data['settings']['main'];

        $json = json_encode($data);

        if ($callback) {
            $ret = "$callback(" . $json . ");";
        } else {
            $ret = $json;
        }

        if ($return) {
            return $ret;
        }
        echo $ret;
        return null;
    }