protected function headerCallBack($ch, $data){
        
        if (!is_null($data)) {
                if (preg_match("~^HTTP/.*? 404~", $data)) {
                   
                    header(trim($data));
                    while (ob_get_level() > 0) {
                        ob_end_flush();
                    }
                }

                if (preg_match("~^Content-disposition~", $data)) {
                    header(str_replace("filename=", 'filename="', trim($data)) . '"');
                    while (ob_get_level() > 0) {
                        ob_end_flush();
                    }
                }

                if (preg_match("~^Content-Type~i", $data)) {
                    header(trim($data));
                    while (ob_get_level() > 0) {
                        ob_end_flush();
                    }
                }
            }
            return strlen($data); //This means that we handled it, so cURL will keep processing
    }