Phusion passenger standalone problem when using send_data for csv?

134 views
Skip to first unread message

Tim

unread,
Dec 19, 2011, 7:20:35 AM12/19/11
to Phusion Passenger Discussions
When running a script using phusion passenger standalone by invoking

rvmsudo passenger start -p 80 --user=user.name

a script with the following code only outputs part of the csv file.

I'm using rails 3.1.1, and have a controller with the following code-

filename = "generated_#{Time.now.localtime.strftime('%Y-%m-%d')}].csv"
csv_file = MyDataModel.export # returns full csv file as string

@output = csv_file.length

# Send to browser
response.headers['Content-Length'] = csv_file.length.to_s
#=begin
send_data 'test'.to_s,
type: 'text/csv', encoding: 'utf8',
disposition: "attachment",
filename: filename,
length: csv_file.length

My guess is that send_data is not setting a content-length which is
why the browser cuts the download immediately. The file should be
about 600kb in size, but truncates transmission at 16kb everytime.


Does anyone know hoe to fix this problem? I want a fill download not a
partial one which is what it's giving me.


If I run the same app using webrick, everything works like a charm.


Thanks in advance

Tim

unread,
Dec 29, 2011, 12:19:54 AM12/29/11
to Phusion Passenger Discussions
This problem does appear to be an nginx issue- likely it is not
sending content-length properly to the browser hence the premature cut
off for the download.


Issue is solved by installing the apache module and using apache
instead after which a full file is always sent to the client. This
does mean that the standalone version of passenger cannot be used at
all in applications that use send_data (at least in my case/server
setup)- if you experience the same, use apache.


Hope this helps someone


Tim
Reply all
Reply to author
Forward
0 new messages