Class: Rack::Adapter::Rails::CGIWrapper
- Inherits:
-
CGI
- Object
- CGI
- Rack::Adapter::Rails::CGIWrapper
- Defined in:
- lib/rack/adapter/rails.rb
Instance Method Summary collapse
-
#args ⇒ Object
Used to wrap the normal args variable used inside CGI.
- #cookies ⇒ Object
-
#env_table ⇒ Object
Used to wrap the normal env_table variable used inside CGI.
- #header(options = 'text/html') ⇒ Object
-
#initialize(request, response, *args) ⇒ CGIWrapper
constructor
A new instance of CGIWrapper.
- #params ⇒ Object
- #query_string ⇒ Object
-
#stdinput ⇒ Object
Used to wrap the normal stdinput variable used inside CGI.
- #stdoutput ⇒ Object
Constructor Details
#initialize(request, response, *args) ⇒ CGIWrapper
Returns a new instance of CGIWrapper.
91 92 93 94 95 96 97 98 |
# File 'lib/rack/adapter/rails.rb', line 91 def initialize(request, response, *args) @request = request @response = response @args = *args @input = request.body super *args end |
Instance Method Details
#args ⇒ Object
Used to wrap the normal args variable used inside CGI.
157 158 159 |
# File 'lib/rack/adapter/rails.rb', line 157 def args @args end |
#cookies ⇒ Object
148 149 150 |
# File 'lib/rack/adapter/rails.rb', line 148 def @request. end |
#env_table ⇒ Object
Used to wrap the normal env_table variable used inside CGI.
162 163 164 |
# File 'lib/rack/adapter/rails.rb', line 162 def env_table @request.env end |
#header(options = 'text/html') ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/rack/adapter/rails.rb', line 100 def header( = 'text/html') if .is_a?(String) @response['Content-Type'] = unless @response['Content-Type'] else @response['Content-Length'] = .delete('Content-Length').to_s if ['Content-Length'] @response['Content-Type'] = .delete('type') || "text/html" @response['Content-Type'] += '; charset=' + .delete('charset') if ['charset'] @response['Content-Language'] = .delete('language') if ['language'] @response['Expires'] = .delete('expires') if ['expires'] @response.status = .delete('Status') if ['Status'] # Convert 'cookie' header to 'Set-Cookie' headers. # Because Set-Cookie header can appear more the once in the response body, # we store it in a line break seperated string that will be translated to # multiple Set-Cookie header by the handler. if = .delete('cookie') = [] case when Array then .each { |c| << c.to_s } when Hash then .each { |_, c| << c.to_s } else << .to_s end @output_cookies.each { |c| << c.to_s } if @output_cookies @response['Set-Cookie'] = [@response['Set-Cookie'], ].compact # See http://groups.google.com/group/rack-devel/browse_thread/thread/e8759b91a82c5a10/a8dbd4574fe97d69?#a8dbd4574fe97d69 if Thin.ruby_18? @response['Set-Cookie'].flatten! else @response['Set-Cookie'] = @response['Set-Cookie'].join("\n") end end .each { |k, v| @response[k] = v } end '' end |
#params ⇒ Object
144 145 146 |
# File 'lib/rack/adapter/rails.rb', line 144 def params @params ||= @request.params end |
#query_string ⇒ Object
152 153 154 |
# File 'lib/rack/adapter/rails.rb', line 152 def query_string @request.query_string end |
#stdinput ⇒ Object
Used to wrap the normal stdinput variable used inside CGI.
167 168 169 |
# File 'lib/rack/adapter/rails.rb', line 167 def stdinput @input end |
#stdoutput ⇒ Object
171 172 173 174 |
# File 'lib/rack/adapter/rails.rb', line 171 def stdoutput STDERR.puts 'stdoutput should not be used.' @response.body end |