Lucee / Railo getHTTPRequestData().content as Binary (workaround)

Had a recent battle with moving over a routine from ACF 9 to Lucee where we had a Flash embed which would send binary data (a generated image) to a CF file to be processed and saved. The routine worked fine under CF9 but failed under Lucee (and Railo).

What appeared to be happening is that Lucee/Railo was forcibly converting content sent as application/octet-stream to string when it should have been binary. You can easily see where this is happening in the Lucee source code, but suffice it to say that while it may be ‘right’ for certain circumstances, it seems pretty wrong to me. There had been bug reports posted and a justification provided for the current behavior, but regardless there is a workaround until/if it gets changed in Lucee.

Where you would normally use getHTTPRequestData().content to get at the binary request body, instead use getPageContext().getRequest().getOriginalRequest().getInputStream() . This gets at the request body from the original unmodified request before Lucee gets it’s hands on it by way of getHTTPRequestData() and avoids the manner in which Lucee abstracts the data in such a way as to mangle binary data.

0 comments… add one

Leave a Comment