简体   繁体   中英

Fetch only the HTTP headers with coldfusion for a remote URL

I have a function that parses urls given to it, and based on the content it finds on that page it decides to use open graph to make embeded videos show up, just display the title, etc.

I want to extend it to detect if a direct video file or music file has been provided as a URL.

I have no interest at all to download the entire contents of the file, but I do want just the headers first to see if it's an audio/mpg, text, html, etc.

Is there a way to get the http headers of a remote file/page without fetching all the content?

Using CFHTTP it will connect and give me the data I need, but it ties up processing time to download the rest of the content.

By knowing the header contents I can decide if I should try and download the entire page to parse it for the extra open graph data.

Try <cfhttp> with 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM