-
-
Save ivanionut/6ed421c30ee77e88adda to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- | |
Does a URL exist? Checks that host exists and for | |
404 status code. | |
http://www.forta.com/blog/index.cfm?mode=day&day=2&month=1&year=2006 | |
---> | |
<cffunction name="urlExists" output="no" returntype="boolean"> | |
<!--- Accepts a URL ---> | |
<cfargument name="u" type="string" required="yes"> | |
<!--- Attempt to retrieve the URL ---> | |
<cftry> | |
<cfhttp method="head" url="#ARGUMENTS.u#" resolveurl="no" throwonerror="no" timeout="2" /> | |
<cfreturn not ( NOT IsDefined("cfhttp.responseheader.status_code") OR cfhttp.responseheader.status_code EQ "404" ) > | |
<cfcatch type="any"> | |
<cfreturn false /><!--- failed to test file location ---> | |
</cfcatch> | |
</cftry> | |
</cffunction> | |
<cfset checkMe = IIF( urlExists( loremUrl ), DE( valA ), DE( valB ) ) /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment