mongrel_secure_download-redux 0.0.3.200 → 0.0.4.201

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,19 +9,37 @@ require 'filemagic/ext'
9
9
  class SecureDownloadRedux < GemPlugin::Plugin '/handlers'
10
10
 
11
11
  # Our version ;-)
12
- VERSION = '0.0.3'
12
+ VERSION = '0.0.4'
13
13
 
14
14
  include Mongrel::HttpHandlerPlugin
15
15
 
16
16
  URL_RE = %r{\A(?:ht|f)tps?://}io
17
17
 
18
- def process(request, response)
18
+ def initialize(options = {})
19
+ super
20
+
19
21
  @base = File.expand_path(@options[:base] || '.')
20
22
 
21
23
  if @base == '/'
22
24
  raise ArgumentError, 'specifying a base path of / is way too dangerous!'
23
25
  end
24
26
 
27
+ @secret = @options[:secret]
28
+
29
+ if @secret.nil? || @secret.empty?
30
+ raise ArgumentError, 'secret missing'
31
+ end
32
+
33
+ @url_method = @options[:url_method] || 'redirect2'
34
+
35
+ if respond_to?(method = "send_url_#{@url_method}", true)
36
+ self.class.send(:alias_method, :send_url, method)
37
+ else
38
+ raise ArgumentError, "unknown URL method #{@url_method}"
39
+ end
40
+ end
41
+
42
+ def process(request, response)
25
43
  @query = Mongrel::HttpRequest.query_parse(request.params['QUERY_STRING'])
26
44
 
27
45
  if !required_params_given? || timeout? || !authorized?
@@ -39,7 +57,6 @@ class SecureDownloadRedux < GemPlugin::Plugin '/handlers'
39
57
  def required_params_given?
40
58
  @status = 500 # Internal Server Error
41
59
 
42
- @secret = @options[:secret] and
43
60
  @path = @query['path'] and
44
61
  @timestamp = @query['timestamp'] and
45
62
  @token = @query['token']
@@ -83,11 +100,6 @@ class SecureDownloadRedux < GemPlugin::Plugin '/handlers'
83
100
  @response.socket.write(Mongrel::Const::REDIRECT % @path)
84
101
  end
85
102
 
86
- # Choose your alternative:
87
- alias_method :send_url, :send_url_read
88
- #alias_method :send_url, :send_url_redirect1
89
- #alias_method :send_url, :send_url_redirect2
90
-
91
103
  def send_file
92
104
  path = File.expand_path(File.join(@base, @path))
93
105
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongrel_secure_download-redux
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.200
4
+ version: 0.0.4.201
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Wille
@@ -49,15 +49,15 @@ has_rdoc: true
49
49
  homepage: http://prometheus.rubyforge.org/mongrel_secure_download-redux
50
50
  post_install_message:
51
51
  rdoc_options:
52
- - --line-numbers
53
- - --main
54
- - README
55
52
  - --title
56
53
  - mongrel_secure_download-redux Application documentation
57
54
  - --inline-source
58
55
  - --charset
59
56
  - UTF-8
60
57
  - --all
58
+ - --main
59
+ - README
60
+ - --line-numbers
61
61
  require_paths:
62
62
  - lib
63
63
  required_ruby_version: !ruby/object:Gem::Requirement