Reputation: 87
I am using ColdFusion 8.
I'm doing a CFHTTP Post to a remote server. The remote site has looked at their logs and they say my code is doing the POST, and then immediately doing a 2nd GET request.
Here is my code (the URL has been changed):
<cfhttp url="https://www.theurlofthesite.com" method="POST" port="443" resolveurl="yes" redirect="yes">
<cfhttpparam type="FORMFIELD" name="type" value="SALES">
<cfhttpparam type="FORMFIELD" name="account" value="10003">
<cfhttpparam type="FORMFIELD" name="Submit" value="Submit+Request">
</cfhttp>
<Cfoutput>#cfhttp.fileContent#</CFOUTPUT>
<cfdump var="#cfhttp#">
Does anyone have any idea why they are seeing a 2nd GET request right after my POST? it's trashing the session and not returing the page correctly because of this (we think)
I'm definately not doing a GET, I'm only doing the one POST.
thanks,
Rich
Upvotes: 4
Views: 2724
Reputation: 87
OK, I switched over to a CF 5 server, and it stopped doing the 2nd GET. it's just doing a POST
now, so it might be a quirk with CF 8.
Upvotes: 0
Reputation: 2384
If you are using firefox, make sure you have firebug and ySlow turned off for your request. They fire your urls twice to set up their data and can be a real problem when you don't know that they are doing that.
Also, try turning the redirect off unless you need it.
Upvotes: 0
Reputation: 786
I'm guessing the reason you get the second GET is that your CFOUTPUT outputs the retrieved page content into the browser, then when an image or something from that content is rendered from the retrieved page it acts as a GET.
Remember that CFHTTP is not stateful. By this I mean that each request with CFHTTP will create a new session. You can get CFHTTP to continue with an existing session by passing in CFID/CFTOKEN through with CFHTTPPARAM in the request. This might explain your session issues.
Upvotes: 5
Reputation: 6802
Is this code inside a custom CF tag? If so then calling
<mytag>...</mytag>
or
<mytag />
Calls the custom tag TWICE! (Once for the start tag and once for the end.)
Upvotes: -1
Reputation: 32885
redirect="false" //maybe?
Not sure... Since the doc said...
If the response header includes a Location field AND ColdFusion receives a 300-series (redirection) status code, specifies whether to redirect execution to the URL specified in the field.
Upvotes: 0