首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OpenSearch + PHP用于激发原子:为什么我可以获得正确的内容类型?

OpenSearch + PHP用于激发原子:为什么我可以获得正确的内容类型?
EN

Stack Overflow用户
提问于 2017-09-13 13:34:15
回答 1查看 262关注 0票数 1

我一直在遵循OpenSearch:https://inspire.ec.europa.eu/documents/technical-guidance-implementation-inspire-download-services下载服务官方技术指南构建一个原子提要

我被困在创建执行搜索的PHP上。

根据前面提到的指南,必须具有以下模板:

代码语言:javascript
复制
<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?}"/> 

该指南还提供了一个PHP脚本来帮助开发人员编写"search.php“文件。剧本的开头是这样的:

代码语言:javascript
复制
$returnFile = false; 
foreach (apache_request_headers() as $name => $value) {
   //echo("$name: $value\n"); 
   if ($name=="Accept" && $value=="application/zip"){ 
      $returnFile = true; 
   } 
}  

如果$returnFile为真,则必须返回一个ZIP文件。如果是false,则返回XML (这是脚本的其余部分)。

我的问题是,条件$name=="Accept" && $value=="application/zip"永远不是真,所以搜索总是返回一个XML。

$value怎么可能是application/zip

这是我在访问Accept时得到的http://myWeb/atom/search.php

代码语言:javascript
复制
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 

编辑:指南提供了更多关于这方面的信息:

代码语言:javascript
复制
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验证器(向search.php发送查询的客户机).我错了吗?

EN

回答 1

Stack Overflow用户

发布于 2017-11-14 13:52:09

我向验证器的开发人员提出了一个问题,他们证实这并不像预期的那样有效。验证器应该在请求中添加“接受”标题,但它将其保留为空白。他们正在解决问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46199031

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档