0

I’m trying to use Helicon Ape’s mod_xsendfile with Railo server (Windows 2012 R2). mod_xsendfile functions correctly and it works fine with PHP, it deliver the file and also it pass the content length value to the browser too. No file size limit found with PHP and no significant use of sever memory regardless the file size.

With Railo, obvious first attempt.

<cfcontent type="text/plain">
<cfheader name="content-disposition" value="attachment; filename=test.txt"/>
<cfheader name="X-Sendfile" value="D:\iis\hello.txt"/>

This does not work. It returns a blank file; no error log generated by Helicon Ape, so it is safe to assume Header X-Sendfile does not passed into IIS/ correctly.

Second Attempt

<cfheader name="content-disposition" value="attachment; filename=test.txt"/>
<cfset Response = GetPageContext().GetResponse() />
<cfset Response.setHeader('X-Sendfile','D:\iis\hello.txt')>
<cfset Response.setContentType('plain/text')>
<cfset Response.GetOutputStream().Flush() />
<cfset Response.Reset() />
<cfset Response.Finish() />

This works with

Limitation 1: When the file size is more than 2GB, browser returns error “ERR_INVALID_CHUNKED_ENCODING” It works fine with smaller file size, no memory issues. (again, PHP seems not to have this issue. IIS do not have a size limit either)

Limitation 2: This does not pass the content-length to the browser, hence browser don’t know the size of the file.

Third Attempt: Add content-length manually. (this is not necessary with PHP)

<cfset filePath = "D:\iis\246.zip">
<cfheader name="content-disposition" value="attachment; filename=246.zip"/>
<cfset Response = GetPageContext().GetResponse() />
<cfset Response.setContentLength( createObject("java","java.io.File").init( filePath ).length() )>
<cfset Response.setHeader('X-Sendfile', filePath )>
<cfset Response.setContentType('application/octet-stream')>
<cfset Response.GetOutputStream().Flush() />
<cfset Response.Reset() />
<cfset Response.Finish() />

Content-length passed into the browser, but unlike with PHP, IIS tries to allocate memory for the file and it soon end up with “Overflow or underflow in the arithmetic operation” error.

I’m sure I’m not handling GetPageContext().GetResponse() correctly. If anyone can help me out here, I would be highly appreciated.

  • How Railo is configured to run in IIS? Have you tried Helicon Zoo to integrate Railo with IIS? https://www.helicontech.com/zoo/docs/java-railo.html Some other connectors limit what modules can be executed after Railo, so current x-sendfile operation is probably server by Railo and not Ape (therefore a memory allocation issues). – Yaroslav Jan 31 '15 at 14:31
  • It is not installed with the Zoo. Railo was already installed in this server. Yes, you are correct. it seems not served by Ape or (not served to Ape from Railo). – user3839184 Jan 31 '15 at 21:48
  • Then how Railo is connected to IIS? I'm not sure about boncode connector, but some others (like jakarta, etc.) are known to prevent IIS from post-processing requests, which means no response filters may apply. Since mod_xsendfile in Ape works as response filter, it cannot act. Zoo connector will work with Ape for sure, you may try to install it. Or try boncode (but I have not tested it). – Yaroslav Feb 03 '15 at 12:06

1 Answers1

0

If you use BonCode to connect to IIS it has facilities for spooling large files without overloading the server mem limit. Thus, allowing efficient streaming. You will need to add the FlushThresholdBytes setting to your BonCode setting (check c:\windows), e.g.:

<FlushThresholdBytes>10240</FlushThresholdBytes>

However, from my limited understanding of Railo it seems to load the whole file into memory which would create a limit on the file size you can stream.

-John