webink 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/bin/rfcgi +31 -13
  2. metadata +4 -4
data/bin/rfcgi CHANGED
@@ -5,12 +5,24 @@ require "webink/beauty"
5
5
  def getBinding(cgi,env,params)
6
6
  return binding
7
7
  end
8
+ def error(cgi, code)
9
+ puts cgi.header
10
+ puts cgi.header("nph" => true, "status" => code, "connection" => "close", "type" => "text/html")
11
+ end
8
12
 
9
13
  script = nil
10
14
  fhandle = nil
11
15
  control = nil
12
16
  pram = nil
17
+ is_production = nil
18
+ use_errors = nil
13
19
  FCGI.each_cgi do |cgi|
20
+ puts cgi.header
21
+ cgi.env_table.each do |k,v|
22
+ puts "#{k}=#{v}<br>"
23
+ end
24
+ is_production = ((cgi.env_table["INK_PRODUCTION"] and eval cgi.env_table["INK_PRODUCTION"]) or (ENV["INK_PRODUCTION"] and eval ENV["INK_PRODUCTION"])) ? true : false
25
+ use_errors = ((cgi.env_table["INK_ERRORS"] and eval cgi.env_table["INK_ERRORS"]) or (ENV["INK_ERRORS"] and eval ENV["INK_ERRORS"])) ? true : false
14
26
  time = Time.now
15
27
  script = cgi.env_table['SCRIPT_FILENAME']
16
28
  begin
@@ -33,7 +45,7 @@ FCGI.each_cgi do |cgi|
33
45
  if v.is_a? Array
34
46
  control[:post][k] = Array.new
35
47
  v.each do |a|
36
- control[:post][k].push (control[:config]["escape_post_data"]) ? CGI::escapeHTML(a) : a
48
+ control[:post][k].push((control[:config]["escape_post_data"]) ? CGI::escapeHTML(a) : a)
37
49
  end
38
50
  control[:post][k] = control[:post][k].to_s
39
51
  else
@@ -55,48 +67,54 @@ FCGI.each_cgi do |cgi|
55
67
 
56
68
 
57
69
  rescue LoadError => bang
58
- if control and control[:config] and not control[:config]["production"]
59
- puts cgi.header({"Location" => "/status-404.html"});
70
+ if not is_production
71
+ puts cgi.header({"Location" => "/status-404.html"}) if use_errors
72
+ error cgi, "NOT_FOUND" if not use_errors
60
73
  else
61
74
  puts cgi.header
62
75
  puts "<hr><b>LoadError:</b>", "<em><pre>", CGI::escapeHTML("#{bang}"), "</pre></em>\n", "<pre>", bang.backtrace.join("\n"), "</pre>"
63
76
  end
64
77
 
65
78
  rescue NotImplementedError => bang
66
- if control and control[:config] and not control[:config]["production"]
67
- puts cgi.header({"Location" => "/status-500.html"});
79
+ if not is_production
80
+ puts cgi.header({"Location" => "/status-500.html"}) if use_errors
81
+ error cgi, "SERVER_ERROR" if not use_errors
68
82
  else
69
83
  puts cgi.header
70
84
  puts "<hr><b>NotImplementedError:</b>", "<em><pre>", CGI::escapeHTML("#{bang}"), "</pre></em>\n", "<pre>", bang.backtrace.join("\n"), "</pre>"
71
85
  end
72
86
 
73
87
  rescue ArgumentError => bang
74
- if control and control[:config] and not control[:config]["production"]
75
- puts cgi.header({"Location" => "/status-500.html"});
88
+ if not is_production
89
+ puts cgi.header({"Location" => "/status-500.html"}) if use_errors
90
+ error cgi, "SERVER_ERROR" if not use_errors
76
91
  else
77
92
  puts cgi.header
78
93
  puts "<hr><b>ArgumentError:</b>", "<em><pre>", CGI::escapeHTML("#{bang}"), "</pre></em>\n", "<pre>", bang.backtrace.join("\n"), "</pre>"
79
94
  end
80
95
 
81
96
  rescue RuntimeError => bang
82
- if control and control[:config] and not control[:config]["production"]
83
- puts cgi.header({"Location" => "/status-500.html"});
97
+ if not is_production
98
+ puts cgi.header({"Location" => "/status-500.html"}) if use_errors
99
+ error cgi, "SERVER_ERROR" if not use_errors
84
100
  else
85
101
  puts cgi.header
86
102
  puts "<hr><b>RuntimeError:</b>", "<em><pre>", CGI::escapeHTML("#{bang}"), "</pre></em>\n", "<pre>", bang.backtrace.join("\n"), "</pre>"
87
103
  end
88
104
 
89
105
  rescue NameError => bang
90
- if control and control[:config] and not control[:config]["production"]
91
- puts cgi.header({"Location" => "/status-500.html"});
106
+ if not is_production
107
+ puts cgi.header({"Location" => "/status-500.html"}) if use_errors
108
+ error cgi, "SERVER_ERROR" if not use_errors
92
109
  else
93
110
  puts cgi.header
94
111
  puts "<hr><b>NameError:</b>", "<em><pre>", CGI::escapeHTML("#{bang}"), "</pre></em>\n", "<pre>", bang.backtrace.join("\n"), "</pre>"
95
112
  end
96
113
 
97
114
  rescue Exception, StandardError => bang
98
- if control and control[:config] and not control[:config]["production"]
99
- puts cgi.header({"Location" => "/status-500.html"});
115
+ if not is_production
116
+ puts cgi.header({"Location" => "/status-500.html"}) if use_errors
117
+ error cgi, "SERVER_ERROR" if not use_errors
100
118
  else
101
119
  puts cgi.header
102
120
  puts "<hr><b>Exception:</b>", "<em><pre>", CGI::escapeHTML("#{bang}"), "</pre></em>\n", "<pre>", bang.backtrace.join("\n"), "</pre>"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webink
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 4
10
- version: 1.1.4
9
+ - 5
10
+ version: 1.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matthias Geier
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-02 00:00:00 +02:00
18
+ date: 2010-10-08 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency