I am trying to get a file from a URL using cfhttp but it seems that the provider is sending the data in chunks.
<cfhttp
method="get"
url="https://www.test.com/somefile.xml">
</cfhttp>
The response header is having Transfer-Encoding as chunked and is missing Content-Length.
Also, the statusCode is 200 Ok but the FileContent is showing "Connection Failure".
Any suggestions?
Finally, I used java.net.URL to get this working:
<cfset local.objURL = createObject(
"java"
, "java.net.URL"
).init( javaCast( "string" , "https://test.com/abc.xml" ) )>
<!--- Input Stream --->
<cfset local.inputStream = local.objURL.openStream()>
<!--- Get Content --->
<cfset local.objScanner = createObject(
"java"
, "java.util.Scanner"
).init( local.inputStream ).useDelimiter( "\\A" )>
<cfset local.fileContent = local.objScanner.hasNext() ? local.objScanner.next() : "">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With