mirror of
https://github.com/beestat/app.git
synced 2025-05-24 02:14:03 -04:00
Fixed data download API calls not logging for #180
Forgot about the set_headers function in Cora.
This commit is contained in:
parent
f0fe1b1760
commit
d0ff64098a
@ -587,24 +587,24 @@ final class cora {
|
||||
* @throws \Exception If this is not a batch request and the content type
|
||||
* was altered from application/json without a custom response.
|
||||
*/
|
||||
// public function set_headers($headers, $custom_response = false) {
|
||||
// if(isset($this->request['batch']) === true) {
|
||||
// if($custom_response === true) {
|
||||
// throw new \Exception('Batch API requests can not use a custom response.', 1015);
|
||||
// }
|
||||
// if($this->content_type_is_json($headers) === false) {
|
||||
// throw new \Exception('Batch API requests must return JSON.', 1014);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// // Not a batch request
|
||||
// if($custom_response === false && $this->content_type_is_json($headers) === false) {
|
||||
// throw new \Exception('Non-custom responses must return JSON.', 1016);
|
||||
// }
|
||||
// }
|
||||
// $this->headers = $headers;
|
||||
// $this->custom_response = $custom_response;
|
||||
// }
|
||||
public function set_headers($headers, $custom_response = false) {
|
||||
if(isset($this->request['batch']) === true) {
|
||||
if($custom_response === true) {
|
||||
throw new \Exception('Batch API requests can not use a custom response.', 1015);
|
||||
}
|
||||
if($this->content_type_is_json($headers) === false) {
|
||||
throw new \Exception('Batch API requests must return JSON.', 1014);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Not a batch request
|
||||
if($custom_response === false && $this->content_type_is_json($headers) === false) {
|
||||
throw new \Exception('Non-custom responses must return JSON.', 1016);
|
||||
}
|
||||
}
|
||||
$this->headers = $headers;
|
||||
$this->custom_response = $custom_response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether or not the current output headers indicate that the
|
||||
|
@ -792,13 +792,13 @@ class runtime_thermostat extends cora\crud {
|
||||
} while ($chunk_end < $download_end);
|
||||
fclose($output);
|
||||
|
||||
header('Content-type: text/csv');
|
||||
header('Content-Length: ' . $bytes);
|
||||
header('Content-Disposition: attachment; filename="Beestat Export - ' . $ecobee_thermostat['identifier'] . '.csv"');
|
||||
header('Pragma: no-cache');
|
||||
header('Expires: 0');
|
||||
|
||||
die();
|
||||
$this->cora->set_headers([
|
||||
'Content-Type' => 'text/csv',
|
||||
'Content-Length' => $bytes,
|
||||
'Content-Disposition' => 'attachment; filename="Beestat Export - ' . $ecobee_thermostat['identifier'] . '.csv"',
|
||||
'Pragma' => 'no-cache',
|
||||
'Expires' => '0',
|
||||
], true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user