1
0
mirror of https://github.com/beestat/app.git synced 2025-06-03 13:46:54 -04:00

Fixed data download API calls not logging for #180

Forgot about the set_headers function in Cora.
This commit is contained in:
Jon Ziebell 2019-11-07 20:28:19 -05:00
parent f0fe1b1760
commit d0ff64098a
2 changed files with 25 additions and 25 deletions

View File

@ -587,24 +587,24 @@ final class cora {
* @throws \Exception If this is not a batch request and the content type * @throws \Exception If this is not a batch request and the content type
* was altered from application/json without a custom response. * was altered from application/json without a custom response.
*/ */
// public function set_headers($headers, $custom_response = false) { public function set_headers($headers, $custom_response = false) {
// if(isset($this->request['batch']) === true) { if(isset($this->request['batch']) === true) {
// if($custom_response === true) { if($custom_response === true) {
// throw new \Exception('Batch API requests can not use a custom response.', 1015); throw new \Exception('Batch API requests can not use a custom response.', 1015);
// } }
// if($this->content_type_is_json($headers) === false) { if($this->content_type_is_json($headers) === false) {
// throw new \Exception('Batch API requests must return JSON.', 1014); throw new \Exception('Batch API requests must return JSON.', 1014);
// } }
// } }
// else { else {
// // Not a batch request // Not a batch request
// if($custom_response === false && $this->content_type_is_json($headers) === false) { if($custom_response === false && $this->content_type_is_json($headers) === false) {
// throw new \Exception('Non-custom responses must return JSON.', 1016); throw new \Exception('Non-custom responses must return JSON.', 1016);
// } }
// } }
// $this->headers = $headers; $this->headers = $headers;
// $this->custom_response = $custom_response; $this->custom_response = $custom_response;
// } }
/** /**
* Return whether or not the current output headers indicate that the * Return whether or not the current output headers indicate that the

View File

@ -792,13 +792,13 @@ class runtime_thermostat extends cora\crud {
} while ($chunk_end < $download_end); } while ($chunk_end < $download_end);
fclose($output); fclose($output);
header('Content-type: text/csv'); $this->cora->set_headers([
header('Content-Length: ' . $bytes); 'Content-Type' => 'text/csv',
header('Content-Disposition: attachment; filename="Beestat Export - ' . $ecobee_thermostat['identifier'] . '.csv"'); 'Content-Length' => $bytes,
header('Pragma: no-cache'); 'Content-Disposition' => 'attachment; filename="Beestat Export - ' . $ecobee_thermostat['identifier'] . '.csv"',
header('Expires: 0'); 'Pragma' => 'no-cache',
'Expires' => '0',
die(); ], true);
} }
/** /**