Commenting exit() and letting function end normally does not solve the problem, i guess it IS a bug, yet..
Here is a full code:
PHP Code:
public function download($format, $str)
{
$get_string = rawurldecode($str);
parse_str($get_string, $get_array);
$webinar_id = $get_array['webinar_id'];
unset($get_array['webinar_id']);
$date = new DateTime();
$str = iconv('UTF-8', 'windows-1251', $this->segmentation_model->do_query($webinar_id, $get_array, $format));
$this->output->set_header('Content-Description: File Transfer');
$this->output->set_header('Content-Type: application/octet-stream');
$this->output->set_header('Content-Disposition: attachment; filename="Segmentation ' . $date->format('Y-m-d H:i:s') . '.' . $format . '"');
$this->output->set_header('Expires: 0');
$this->output->set_header('Cache-Control: must-revalidate');
$this->output->set_header('Pragma: public');
$this->output->set_header('Content-Length: ' . strlen($str));
echo $str;
}
And what Chrome receives (Response Headers):
Code:
HTTP/1.1 200 OK
Date: Tue, 29 Dec 2015 13:25:37 GMT
Server: Apache/2.2.29 (Win32) mod_ssl/2.2.29 OpenSSL/1.0.1j PHP/5.4.36
X-Distributor: AHC
X-Powered-By: PHP/5.4.36
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS
Access-Control-Allow-Headers: X-Requested-With, Content-Type, Content-Range, Content-Disposition, Content-Description,*
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
Simply replacing '$this->output->set_header' with 'header' yields:
Code:
HTTP/1.1 200 OK
Date: Tue, 29 Dec 2015 13:27:41 GMT
Server: Apache/2.2.29 (Win32) mod_ssl/2.2.29 OpenSSL/1.0.1j PHP/5.4.36
X-Distributor: AHC
X-Powered-By: PHP/5.4.36
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS
Access-Control-Allow-Headers: X-Requested-With, Content-Type, Content-Range, Content-Disposition, Content-Description,*
Expires: 0
Cache-Control: must-revalidate
Pragma: public
Content-Description: File Transfer
Content-Disposition: attachment; filename="Segmentation 2015-12-29 16:27:42.txt"
Content-Length: 39132
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/octet-stream
At least 5-6 lines are different, inc. Pragma, Content-Type, missing filename, etc, but most importantly second example works when first - doesn't!
Thanks for Download Helper, I'll try it.