CFHTTP only returns filecontent for GET methods

I just wanted to drop in here and say that I ran into a similar issue. Using CommandBox to spin up a Lucee server with no additional configuration. I was testing the use of CFHTTP with redirects:

<cfscript>

	methods = [ "GET", "POST", "PUT", "PATCH", "DELETE" ];

	results = methods.map(
		( method ) => {

			http
				result = "local.httpResponse"
				method = method
				url = "http://127.0.0.1:58662/07-fetch-status/api.cfm"
				redirect = "yes"
			;

			return httpResponse.fileContent;

		}
	);

	dump( results );

</cfscript>

For any non-GET request, the HTTP response fileContent just comes back with Document Moved and does not follow the redirect.

Like I said, it’s just a CommandBox server with no special config. Only dropping this note here to commiserate with anyone else that runs into this issue. I didn’t get it solved.

ahhh, i see, it’s a bug yeah?

https://hc.apache.org/httpcomponents-client-4.5.x/current/httpclient/apidocs/org/apache/http/impl/client/LaxRedirectStrategy.html

Lucee is currently using the stricter default, so we don’t match ACF behaviour here?

https://hc.apache.org/httpcomponents-client-4.5.x/current/httpclient/apidocs/org/apache/http/impl/client/DefaultRedirectStrategy.html

To be honest, I have no idea if it’s a bug; other than the documentation in CFHTTP says that it follows redirects. I never use this in my CFML APIs - i was just testing something to see how it compared to the fetch() API in the browser (fetch will propagate the HTTP Method upon redirect for non-GET/POST requests - I wanted to see if cfhttp also did this).

All to say, I don’t feel strongly about it one way or the other :smiley:

https://luceeserver.atlassian.net/browse/LDEV-5542

Playing with it now, it’s a spec violation but FAFO

Added to Lucee 7.0.0.208, support for <cfhttp redirect='lax'>

Here’s @bennadel’s blog post related to this

2 Likes

You’re too fast :smiley: :smiley:

Along the way I fixed the population of the redirect chain logging too!

https://luceeserver.atlassian.net/browse/LDEV-3728