我有一个函数可以解析给它的网址,并根据在该页面上找到的内容决定使用开放图来显示嵌入视频,仅显示标题等。
我想扩展它来检测是否已将直接视频文件或音乐文件作为 URL 提供。
我根本没有兴趣下载文件的全部内容,但我确实只想先查看标题,看看它是否是音频/mpg、文本、html 等。
有没有办法获取远程文件/页面的http header 而不获取所有内容?
使用 CFHTTP,它将连接并为我提供所需的数据,但它占用了下载其余内容的处理时间。
通过了解 header 内容,我可以决定是否应该尝试下载整个页面以解析它以获取额外的开放图形数据。
最佳答案
尝试<cfhttp>
与 method="head"
HEAD: identical to the GET method, but the server does not send a message body in the response. Use this method for testing hypertext links for validity and accessibility, determining the type or modification time of a document, or determining the type of server.
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7ffc.html
关于coldfusion - 使用 Coldfusion 仅获取远程 URL 的 HTTP header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6312406/