Description:
added option for Apapche X-Sendfile
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@370 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r172:400ab663b3b9 - - 2 files changed: 13 inserted, 9 deleted
@@ -11,33 +11,33 | |||
|
11 | 11 | @user = User.find(session[:user_id]) |
|
12 | 12 | end |
|
13 | 13 | |
|
14 | 14 | def view |
|
15 | 15 | base_filename = File.basename("#{params[:file]}.#{params[:ext]}") |
|
16 | 16 | filename = "#{RAILS_ROOT}/data/tasks/#{base_filename}" |
|
17 | 17 | #filename = "/home/ioi/web_grader/data/tasks/#{base_filename}" |
|
18 | 18 | #filename = "/home/ioi/web_grader/public/images/rails.png" |
|
19 | 19 | if !FileTest.exists?(filename) |
|
20 | 20 | redirect_to :action => 'index' and return |
|
21 | 21 | end |
|
22 | 22 | |
|
23 | - response.headers['Content-Type'] = "application/force-download" | |
|
24 | - response.headers['Content-Disposition'] = "attachment; filename=\"#{File.basename(filename)}\"" | |
|
25 | - response.headers["X-Sendfile"] = filename | |
|
26 |
- response.headers[ |
|
|
27 | - render :nothing => true | |
|
28 | - | |
|
29 | - return | |
|
30 | - | |
|
31 | - send_file filename, :stream => false, :filename => base_filename | |
|
23 | + if defined?(USE_APACHE_XSENDFILE) and USE_APACHE_XSENDFILE | |
|
24 | + response.headers['Content-Type'] = "application/force-download" | |
|
25 | + response.headers['Content-Disposition'] = "attachment; filename=\"#{File.basename(filename)}\"" | |
|
26 | + response.headers["X-Sendfile"] = filename | |
|
27 | + response.headers['Content-length'] = File.size(filename) | |
|
28 | + render :nothing => true | |
|
29 | + else | |
|
30 | + send_file filename, :stream => false, :filename => base_filename | |
|
31 | + end | |
|
32 | 32 | end |
|
33 | 33 | |
|
34 | 34 | protected |
|
35 | 35 | |
|
36 | 36 | def check_viewability |
|
37 | 37 | user = User.find(session[:user_id]) |
|
38 | 38 | if user==nil or !Configuration.show_tasks_to?(user) |
|
39 | 39 | redirect_to :controller => 'main', :action => 'list' |
|
40 | 40 | return false |
|
41 | 41 | end |
|
42 | 42 | end |
|
43 | 43 |
@@ -78,12 +78,16 | |||
|
78 | 78 | TEST_REQUEST_OUTPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/output' |
|
79 | 79 | |
|
80 | 80 | # To use ANALYSIS MODE, provide the testcases/testruns breakdown, |
|
81 | 81 | # and the directory of the grading result (usually in judge's dir). |
|
82 | 82 | TASK_GRADING_INFO_FILENAME = RAILS_ROOT + '/config/tasks.yml' |
|
83 | 83 | GRADING_RESULT_DIR = '/home/thailandoi/ytopc/judge/result' |
|
84 | 84 | |
|
85 | 85 | # Uncomment so that configuration is read only once when the server is loaded |
|
86 | 86 | # Configuration.enable_caching |
|
87 | 87 | |
|
88 | 88 | # Uncomment so that the system validates user e-mails |
|
89 | 89 | # VALIDATE_USER_EMAILS = true |
|
90 | + | |
|
91 | + # Uncomment so that Apache X-Sendfile is used when delivering files | |
|
92 | + # (e.g., in /tasks/view). | |
|
93 | + # USE_APACHE_XSENDFILE = true |
You need to be logged in to leave comments.
Login now