OpenSearch + PHP for INSPIRE ATOM : Why can I get the correct Content-Type?

330 views Asked by At

I've been following the official Technical Guide for Download Services of INSPIRE to build an ATOM feed with OpenSearch: https://inspire.ec.europa.eu/documents/technical-guidance-implementation-inspire-download-services

I'm stuck at creating the PHP that performs the search.

According to the before mentioned guide, the OpenSearch description XML has to have these templates:

<Url type="application/zip" rel="results" template="http://myWeb/atom/search.php?spatial_dataset_identifier_code={inspire_dls:spatial_dataset_identifier_code?}&amp;spatial_dataset_identifier_namespace={inspire_dls:spatial_dataset_identifier_namespace?}&amp;crs={inspire_dls:crs?}&amp;language={language?}&amp;q={searchTerms?}"/>    

<Url type="application/atom+xml" rel="describedby" template="http://myWeb/atom/search.php?spatial_dataset_identifier_code={inspire_dls:spatial_dataset_identifier_code?}&amp;spatial_dataset_identifier_namespace={inspire_dls:spatial_dataset_identifier_namespace?}&amp;crs={inspire_dls:crs?}&amp;language={language?}&amp;q={searchTerms?}"/> 

The same guide has a PHP script to help the developer write the "search.php" file. That script starts like this:

$returnFile = false; 
foreach (apache_request_headers() as $name => $value) {
   //echo("$name: $value\n"); 
   if ($name=="Accept" && $value=="application/zip"){ 
      $returnFile = true; 
   } 
}  

If $returnFile is true, a ZIP file must be returned. If it is false, an XML is returned (that is what the rest of the script does).

My problem is that the condition $name=="Accept" && $value=="application/zip" is never true, so the search always returns an XML.

How can $value be application/zip?

This is the Accept value that I get when accessing http://myWeb/atom/search.php:

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 

EDIT: The guide tells something more about this:

The example given in Annex A uses content negotiation to identify which 
operation to perform. This means that even though the operation endpoint is 
only one, i.e. http://myWeb/search.php, the client has to set the HTTP 
―Accept‖ Header to the correct value in order to receive the expected 
result.

So, if I test my ATOM feed in the INSPIRE validator, the client is the INSPIRE validator (the one that sends the queries to search.php)... am I wrong?

1

There are 1 answers

0
O.D. On BEST ANSWER

I opened an issue with the developers of the validator and they confirmed that is not working as expected. The validator should add the 'Accept' header in the request, but it leaves it blank. They are working in a fix.