INSPIRE的OpenSearch + PHP原子:为什么我可以得到正确的Content-Type?
问题描述:
我一直在关注官方技术指南INSPIRE的下载服务,以建立一个ATOM饲料用的OpenSearch:https://inspire.ec.europa.eu/documents/technical-guidance-implementation-inspire-download-servicesINSPIRE的OpenSearch + PHP原子:为什么我可以得到正确的Content-Type?
我被困在创建执行搜寻PHP
。
根据之前提到的指导,OpenSearch说明XML必须有这些模板:
同样的引导有PHP
脚本来帮助开发人员编写了“的search.php”文件。该脚本如下所示:
$returnFile = false;
foreach (apache_request_headers() as $name => $value) {
//echo("$name: $value\n");
if ($name=="Accept" && $value=="application/zip"){
$returnFile = true;
}
}
如果$returnFile
为true,则必须返回ZIP文件。如果它是假的,则返回一个XML(这是脚本的其余部分所做的)。
我的问题是条件$name=="Accept" && $value=="application/zip"
永远不是真的,所以搜索总是返回一个XML。
$value
怎么可能是application/zip
?
这是Accept
值访问时http://myWeb/atom/search.php
,我得到:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
编辑:导游告诉更多的东西一下:
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.
所以,如果测试我ATOM供稿在INSPIRE验证器中,客户端是INSPIRE验证器(将查询发送到search.php的验证器)...我错了吗?
答
我向验证程序的开发人员提出了一个问题,他们确认该程序无法按预期工作。验证程序应该在请求中添加“Accept”标头,但它会将其留空。他们正在修复。