api - ColdFusion 10 REST API : site-wide error handler (AbortException) gets called when returning file

标签 api rest coldfusion coldfusion-10

我正在使用 ColdFusion 10 的新 REST API。在其中一个端点,我返回一个如下文件:

<cffunction name="getFil"
            access="remote"
            httpmethod="GET"
            restpath="{id}/fil"
            returntype="void">
    <cfargument name="id" required="true" restargsource="path" type="numeric" />

        <cfprocessingdirective suppresswhitespace="no">
            <cfheader name="Content-Disposition" value="attachment; filename=foo.pdf" />
            <cfheader name="Content-Type" value="application/pdf"> 
            <cfcontent file="C:/some_path_to_file/foo.pdf" deletefile="no" />
        </cfprocessingdirective>

</cffunction>

它工作正常并响应 200 OK,后面是响应正文中的文件。即使响应良好,站点范围的错误处理程序也会被调用,错误消息如下所示:

[coldfusion.runtime.AbortException : null] null <br>The error occurred on line 124.

客户端永远不会看到错误,但当调用站点范围的错误处理程序时,我的电子邮件服务会向开发人员发送通知电子邮件。有人知道这个 AbortException 是什么以及如何防止它吗?

最佳答案

怀疑某些停止处理的CFML标签(如本例中的<cfcontent>)似乎使用<cfabort>代码来执行此操作。我现在不记得如何重现它,但是 <cfabort>确实会在后台引发异常(并且 AbortException 听起来不错),但 ColdFusion 在很大程度上会抑制它。 REST 请求不使用与普通 CF 请求相同的 servlet,因此也许它不太擅长抑制它?

如果您(出于测试目的,暂时)删除 <cfcontent> ,我希望不会发生异常。

我觉得我对这里的一些细节有点模糊,但我现在无法对其进行彻底的测试。对于那个很抱歉。当我有时间时,我会尝试将事情确定下来并听起来更明确。

关于api - ColdFusion 10 REST API : site-wide error handler (AbortException) gets called when returning file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21294715/

相关文章:

api - 通过单个 API 调用获取 CKAN 中资源的数据集 ID/名称?

rest - 使用 POST 而不是 PUT REST

JavaScript 变量到 ColdFusion 变量

java - 从 Spring Boot Rest 服务下载文件

html - 在 ColdFusion 中使用表单数组?

encryption - ColdFusion解密编码不一样

linux - 写出 libjpeg 图像时内存泄漏

android - Google Places API 请求调用

c++ - 公开回调 API 的最佳方式是什么 - C++

rest - http post - 如何发送授权 header ?