Skip to content
Snippets Groups Projects
Commit f3e06b10 authored by Guilherme Arthur Gerônimo's avatar Guilherme Arthur Gerônimo
Browse files

Merge branch '14_smallrequests' into 'main'

Fix #14

See merge request !11
parents db640265 95d25e18
No related branches found
No related tags found
1 merge request!11Fix #14
......@@ -58,7 +58,5 @@ if ( isset( $response['headers'] ) ){
foreach ( $response['headers'] as $header )
header( $header );
} else {
//TODO Maybe this will not be used due all queries use x-sendfile
error_log("Query not using X-SendFile!");
echo $response;
}
......@@ -80,7 +80,12 @@ namespace SmartData\SmartAPI
}
if($return != NULL) {
$pos = 0;
$isBigQuery = false;
$bigUnits = [0x02240003, 0x02230000, 0x03020000]; //Image, WAV, LIDAR
foreach ( $return['series'] as $key => $sd ) {
//Check if the series are a "big unit"
$isBigQuery = in_array( $sd['unit'] & 0x0FFF0000 , $bigUnits );
$ver = intval( $sd['version'] );
$return['series'][$pos]['version'] = ( $ver >> 4 ) . "." . ( $ver & 0x0F );
if (array_key_exists("SmartData", $sd)) {
......@@ -95,6 +100,7 @@ namespace SmartData\SmartAPI
}
// The following lines dumps the response to a file and uses X-SendFile to notify Apache to send the response.
// this saves a lot of memory.
if ( $isBigQuery ) {
$file_path_for_digital_series = '/smartdata/tmp/' . microtime(true) . '.gets';
file_put_contents($file_path_for_digital_series, '{"series": [' , FILE_APPEND);
foreach ( $return['series'] as $key => $sd ) {
......@@ -107,6 +113,9 @@ namespace SmartData\SmartAPI
$return['headers'][] = 'X-Sendfile: ' . $file_path_for_digital_series ;
$return['headers'][] = 'Content-type: application/json' ;
$return['headers'][] = 'Content-Length: ' . (filesize( $file_path_for_digital_series ) + 1) ;
} else {
$return = json_encode( $return, JSON_NUMERIC_CHECK );
}
} else {
throw new RequestFailedException("Error processing request: null return");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment