Checking website with cfhttp

Posted on 2013-09-05
Medium Priority
Last Modified: 2013-09-09
Hello experts-

I have a list of websites I wanted to loop through and check to see if they are running.  I am checking the head in the cfhttp tag, but not getting the cfhttp.responseheader.status_code.

Any help would be appreciated

<cfset urlList ='http://www.keywordconnectss.com,http://google.com, http://www.marano-us.com,http://www.yahoo.com,http://www.espnnn.com'>
<cfloop list="#urlList#" index="i">
	<cfhttp method="head" url="#i#">


 <cfif isDefined("cfhttp.responseheader.status_code")>
 	<cfset status =  #cfhttp.responseheader.status_code#>
    <cfset status = 404>
    #status#<br />

Open in new window

Question by:nmarano
LVL 53

Accepted Solution

_agx_ earned 2000 total points
ID: 39467776
I'm not near a CF install right now, but what do you mean by not found?

You can always use cfhttp.statusCode.  It includes both the status code and text. Just use list functions to grab the code number:
        <cfset status = listFirst(cfhttp.statusCode, " ")>

BTW, cfhttp.statusCode should always be defined. So you shouldn't need isDefined.

Author Comment

ID: 39467919
thanks will try that

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question