On Saturday, Mar 8, 2003, at 10:17 US/Pacific, David Fafard wrote:
> I am getting nowhere trying to cfhttp a local .cfm page
> from my server. Here is the line of code throwing the error.
>
> <cfhttp url="http://www.mydomain.com/pdf.cfm"
> throwonerror="Yes"></cfhttp>
>
> This gives me the "302 Moved Temporarily" error if I include
> throwonerror="Yes" attribute.
Does that page use cflocation? Is it trying to deliver a PDF via some
means? If so, I'd expect to see 302 - a redirect - you can always get
the real URL. I posted the code here I think a day or two ago - here it
is again:
<!--- wget.cfc --->
<cfcomponent>
<cffunction name="call" access="public" returntype="struct">
<cfargument name="address" type="string"
required="true"/>
<cfset var httpResult = structNew()/>
<cfset httpResult.location = arguments.address/>
<cftry>
<cfhttp url="#arguments.address#"
charset="ISO-8859-1" timeout="120"
useragent="Mozilla/5.0 (Macintosh; U;
PPC Mac OS X; en-US; rv:1.2.1) Gecko/20021130">
</cfhttp>
<cfset httpResult.statusCode =
left(cfhttp.statusCode,3)/>
<cfset httpResult.extendedStatusCode =
cfhttp.statusCode/>
<cfset httpResult.location = arguments.address/>
<cfif httpResult.statusCode eq "301" or
httpResult.statusCode eq "302">
<cfset httpResult.location =
cfhttp.responseHeader["Location"]/>
</cfif>
<cfcatch type="any">
<cfset httpResult.statusCode = "999"/>
<cfset httpResult.extendedStatusCode =
"Exception thrown."/>
</cfcatch>
</cftry>
<cfreturn httpResult/>
</cffunction>
</cfcomponent>
Use it like this:
<cfinvoke component="wget" method="call" address="#destination#"
returnvariable="webStatus">
<cfset httpStatus = webStatus.statusCode/>
<cfswitch expression="#httpStatus#">
<cfcase value="200"><!--- OK ---></cfcase>
<cfcase value="301,302">
<cfset redirectTo = webStatus.location/>
<!--- go get redirectTo URL --->
</cfcase>
...
</cfswitch>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for
dependable ColdFusion Hosting.
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4