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.
154 155 156 157 158 159 160 161 |
# File 'lib/rack/adapter/rails.rb', line 154 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.
214 215 216 |
# File 'lib/rack/adapter/rails.rb', line 214 def args @args end |
#cookies ⇒ Object
205 206 207 |
# File 'lib/rack/adapter/rails.rb', line 205 def @request. end |
#env_table ⇒ Object
Used to wrap the normal env_table variable used inside CGI.
219 220 221 |
# File 'lib/rack/adapter/rails.rb', line 219 def env_table @request.env end |
#header(options = "text/html") ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/rack/adapter/rails.rb', line 163 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'] = unless .empty? end .each { |k,v| @response[k] = v } end "" end |
#params ⇒ Object
201 202 203 |
# File 'lib/rack/adapter/rails.rb', line 201 def params @params ||= @request.params end |
#query_string ⇒ Object
209 210 211 |
# File 'lib/rack/adapter/rails.rb', line 209 def query_string @request.query_string end |
#stdinput ⇒ Object
Used to wrap the normal stdinput variable used inside CGI.
224 225 226 |
# File 'lib/rack/adapter/rails.rb', line 224 def stdinput @input end |
#stdoutput ⇒ Object
228 229 230 231 |
# File 'lib/rack/adapter/rails.rb', line 228 def stdoutput STDERR.puts "stdoutput should not be used." @response.body end |