Skip to main content
Known Participant
September 1, 2010
Question

how to resolve this cfhttp issue

  • September 1, 2010
  • 2 replies
  • 938 views

Hi i had site url like this


http://test.com/123/files

and in files folder we have like 10-15 text files like test1.txt,test2.txt,test3.txt...etc

i am using this code to check files exists in server and if file exits then display this user with below code

<cfhttp method="get" url="http://test.com/123/files/test1txt"  />
    <cfset header = cfhttp.header /> 
   
     <cfif listContainsNoCase(header, "200 OK")>
        <cflocation url="http://test.com/123/files/test1.txt">       
    <cfelse>   
        <cfset request.proginfo.pagemessage="The  file  was not found."/>       
        <cflocation url="stest.cfm"> 
    </cfif>

I have a problem with this , if even my files are there in server i am getting message that file not exits but the file is there in sever and this happens some times and sometimes i am not seeing any error.

Is there any better way to do this as i am using coldfusion8 now.

Thanks

This topic has been closed for replies.

2 replies

September 2, 2010

Plz try with

<cfif #cfhttp.statusCode# eq "200 OK">

Proceed

<cflese>

Error

cfnewAuthor
Known Participant
September 2, 2010

hi even if i use #cfhttp.ststuscode# or 3cfhttp.header# gives me same result "200 OK" , but my problem is that still files are there in server and when i am using cfhttp i am getting message file not found .

i need to know is there is any better way to trace this error.

Thanks

ilssac
Inspiring
September 2, 2010

A cfhttp request is just like a http request that a human user would make with a browser.

As such it goes through the web server, and is probably logged by said server.

I might look at the web server log for these requests and see why it is responding the way it is responding.

Inspiring
September 1, 2010

In the sample you've posted the values of the url attributes in CFHTTP and CFLOCATION are not identical, they should be.  This could account for the problem if the code is similar to your production code.