Hi. I'm trying to download file by CFHTTP Lucee 5....
# lucee
r
Hi. I'm trying to download file by CFHTTP Lucee 5.3.9.166. Web-server response has header "Content-Type: application/pdf;charset=binary" and I get "Lucee 5.3.9.166 Error (java.nio.charset.UnsupportedCharsetException) Message: binary". ACF works fine with the same code. If web-server doesn't return "charset=binary" it works fine. Any ideas how to fix it?
z
stacktrace?
r
*Java Stacktrace*lucee.runtime.exp.NativeException: binary at java.base/java.nio.charset.Charset.forName(Charset.java:529) at lucee.commons.io.CharsetUtil.toCharset(CharsetUtil.java:53) at lucee.runtime.tag.Http._doEndTag(Http.java:1144) at lucee.runtime.tag.Http.doEndTag(Http.java:697) at appserver.test.test20221108_cfm$cf$9.call(/Innovare/AppServer/test/test20221108.cfm:15) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1023) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:946) at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:927) at appserver.application_cfc$cf.udfCall(/innovare/AppServer/Application.cfc:87) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350) at lucee.runtime.type.UDFImpl.call(UDFImpl.java:223) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:663) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:585) at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1932) at lucee.runtime.listener.ModernAppListener.call(ModernAppListener.java:444) at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:218) at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:44) at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2490) at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2476) at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2447) at lucee.runtime.engine.Request.exe(Request.java:45) at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1198) at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1144) at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:97) at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51) at javax.servlet.http.HttpServlet.service(HttpServlet.java:590) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.cfmlprojects.regexpathinfofilter.RegexPathInfoFilter.doFilter(RegexPathInfoFilter.java:47) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:117) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at runwar.Server$1.handleRequest(Server.java:510) at io.undertow.servlet.handlers.SendErrorPageHandler.handleRequest(SendErrorPageHandler.java:52) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:280) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:79) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:134) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:131) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:260) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:79) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:100) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:387) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:852) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1280) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.nio.charset.UnsupportedCharsetException: binary ... 66 more
I found the same error here. It was in 2017 🙂 https://dev.lucee.org/t/lucee-cfhttp-get-error/2773
I reproduced this bug: enpoint.cfm: <cfcontent reset="true"> <cfcontent file="c:\17797.pdf" type="application/pdf; charset=binary"> caller.cfm <cfhttp method="GET" url="...enpoint.cfm"> </cfhttp>
z
can you file a bug in jira?
r
z
r
I'll do it
are there any tricks how to resolve it? I think about proxy on ACF server... but maybe I can overwrite content-type before cfhttp parsing (cfhttp hooks?) or something else?
m
maybe that is because Lucee simply was to forgiving on that, problem seem to be that this is simply invalid “Content-Type: application/pdf;charset=binary”
and older version simply did ignore this
z
is that a workaround to lucee appending charset:utf-8 ?
m
the exception itself is correct “java.nio.charset.UnsupportedCharsetException: binary”
a workaround is to not set “binary” as a charset when no charset is needed
m
still we will look into it and ignore any charsedt defintion if not needed
z
@pothys-mitrahsoft can we test this now with _internalRequest as it supports charset since recently?
r
m
i have fixed in for Lucee 5.3.10
and 6.0
z
that's a 30 minute turnaround, not bad eh?
r
yeah! really cool! thanks!
p
@zackster Yeah, we can add a test for content type using _internalRequest(). But I don't think that covers this issue in the cfhttp tag for this particular scenario 🙂
m
@romanstr i also backported the fix in a simplified for to Lucee 5.3.9
5.3.9.167 to be exact
all building atm
please give it a test
👍 1
g
@garciadev is this the same as we saw, I dont think it is?
r
@micha I checked in 9.3.9.167 and it works! thank you!
🎉 2
p
@micha works fine for me in all the fixed-version builds
g
@gpickin we had a different error. For us, the CFHTTP request would return a result, it was just the filecontent that was different between 5.3.8 and 5.3.9
z
steps to reproduce?
actually let's start a new thread yeah?