Skip to main content
Inspiring
March 16, 2009
Question

CFC problem ??

  • March 16, 2009
  • 9 replies
  • 963 views
I have the following CFC:

<cfcomponent displayname="getURL">
<cffunction name="get" access="public" returntype="string">
<cfhttp
url="https://www.memberst.com/Programs/Redirector.aspx?cid=2081"
redirect="no" port="443"></cfhttp>
<cfset wholeStringLength=len(cfhttp.responseHeader.Location)>
<cfset urlString=findnocase("=",cfhttp.responseHeader.Location)>
<cfset returnString=trim(mid(cfhttp.responseHeader.Location,(urlString
+ 1),wholeStringLength))>

<cfreturn returnString>
</cffunction>
</cfcomponent>

It had been working earlier today, and now I'm getting a message that says:

Element RESPONSEHEADER.LOCATION is undefined in CFHTTP

If I go to the url listed in the cfc, the
https://www.memberst.com/Programs/Redirector.aspx?cid=2081 the browser
pulls up the page just fine.....

Any thoughts on what direction to look in????
    This topic has been closed for replies.

    9 replies

    Inspiring
    March 17, 2009
    and you can significantly simplify your code by using ListLast() function:

    <cffunction name="get" access="public" returntype="string">
    <cfhttp url="https://www.memberst.com/Programs/Redirector.aspx?cid=2081"
    redirect="no" port="443"></cfhttp>
    <cfreturn listlast(cfhttp.responseHeader.Location, "=")>
    </cffunction>

    make sure you add some error handling in there in case of netwrok
    errors/request timeout/requested url unavailable/etc


    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    Inspiring
    March 17, 2009
    you need the <cfdump> INSIDE the function, not after it!

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    Inspiring
    March 16, 2009
    Its on a hosted solution, so no, I can't get access to the server.....

    Ian Skinner wrote:
    > Steve G wrote:
    >> I get:
    >> Variable CFHTTP is undefined
    >>
    >
    > Then the <cfhttp...> request is not completing.
    >
    > Can you do this request manually from the ColdFusion server as the
    > ColdFusion user?
    Inspiring
    March 16, 2009
    Steve G wrote:
    > I get:
    > Variable CFHTTP is undefined
    >

    Then the <cfhttp...> request is not completing.

    Can you do this request manually from the ColdFusion server as the
    ColdFusion user?
    Inspiring
    March 16, 2009
    I get:
    Variable CFHTTP is undefined

    When the CFC is written as:
    <cfcomponent displayname="getURL">
    <cffunction name="get" access="public" returntype="string">
    <cfhttp
    url="https://www.memberst.com/Programs/Redirector.aspx?cid=2081"
    redirect="no" port="443"></cfhttp>
    <cfset wholeStringLength=len(cfhttp.responseHeader.Location)>
    <cfset urlString=findnocase("=",cfhttp.responseHeader.Location)>
    <cfset returnString=trim(mid(cfhttp.responseHeader.Location,(urlString
    + 1),wholeStringLength))>

    <cfreturn returnString>
    </cffunction>
    <cfdump var="#cfhttp#">
    </cfcomponent>

    Ian Skinner wrote:
    > Steve G wrote:
    >> So you're saying do a <cfdump> in the CFC??
    >>
    >
    > Well yes.
    >
    > <cfhttp....></cfhttp>
    > <cfdump var="#cfhttp#"><cfabort>
    >
    > And see if what you see provides in clues.
    Inspiring
    March 16, 2009
    Steve G wrote:
    > So you're saying do a <cfdump> in the CFC??
    >

    Well yes.

    <cfhttp....></cfhttp>
    <cfdump var="#cfhttp#"><cfabort>

    And see if what you see provides in clues.
    Inspiring
    March 16, 2009
    So, if I change the CFC to:

    <cfcomponent displayname="getURL">
    <cffunction name="get" access="public" returntype="string">
    <cfhttp
    url="https://www.memberst.com/Programs/Redirector.aspx?cid=2081"
    redirect="no" port="443"></cfhttp>
    <cfset wholeStringLength=len(cfhttp.responseHeader.Location)>
    <cfset urlString=findnocase("=",cfhttp.responseHeader.Location)>
    <cfset returnString=trim(mid(cfhttp.responseHeader.Location,(urlString
    + 1),wholeStringLength))>

    <cfreturn returnString>
    </cffunction>
    <cfdump var="#cfhttp.responseHeader#">
    </cfcomponent>

    I get:
    Element RESPONSEHEADER is undefined in CFHTTP.

    Ian Skinner wrote:
    > Steve G wrote:
    >> Any thoughts on what direction to look in????
    >
    > Dump out the response in your function to make sure ColdFusion is
    > getting the same response as you do as ColdFusion is most likely not
    > running with the same permissions that you have and that can greatly
    > affect the outcomes of requests like this.
    >
    > And I am to rushed to even consider rewording that run on sentence.
    Inspiring
    March 16, 2009
    So you're saying do a <cfdump> in the CFC??

    Ian Skinner wrote:
    > Steve G wrote:
    >> Any thoughts on what direction to look in????
    >
    > Dump out the response in your function to make sure ColdFusion is
    > getting the same response as you do as ColdFusion is most likely not
    > running with the same permissions that you have and that can greatly
    > affect the outcomes of requests like this.
    >
    > And I am to rushed to even consider rewording that run on sentence.

    Inspiring
    March 16, 2009
    Steve G wrote:
    > Any thoughts on what direction to look in????

    Dump out the response in your function to make sure ColdFusion is
    getting the same response as you do as ColdFusion is most likely not
    running with the same permissions that you have and that can greatly
    affect the outcomes of requests like this.

    And I am to rushed to even consider rewording that run on sentence.