Skip to content
Snippets Groups Projects
Commit f3f4e34c authored by alvaro's avatar alvaro
Browse files

Check if http request returned a 200 status before writing to cache

parent 42f731bc
No related branches found
No related tags found
No related merge requests found
...@@ -57,9 +57,10 @@ class Endpoint{ ...@@ -57,9 +57,10 @@ class Endpoint{
echo("Error executing SPARQL query (".$this->sparqlUrl."): ".curl_error($c)); echo("Error executing SPARQL query (".$this->sparqlUrl."): ".curl_error($c));
} }
} }
$http_status = intval(curl_getinfo($c, CURLINFO_HTTP_CODE));
curl_close($c); curl_close($c);
$this->params['output'] = $auxoutput; $this->params['output'] = $auxoutput;
if(is_int($conf['cache']['global']) && $conf['cache']['global'] > 0){ if(is_int($conf['cache']['global']) && $conf['cache']['global'] > 0 && $http_status == 200){
file_put_contents($cacheFile,($aux), LOCK_EX); file_put_contents($cacheFile,($aux), LOCK_EX);
if($conf['debug']){ if($conf['debug']){
$msg = "Notice: Writing results in ".$cacheFile."\n"; $msg = "Notice: Writing results in ".$cacheFile."\n";
......
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