Module: Webbed::Helpers::RackRequestHelper::InstanceMethods
- Defined in:
- lib/webbed/helpers/rack_request_helper.rb
Instance Attribute Summary (collapse)
-
- ({String => String}) rack_env
The Rack environment of the Request.
Instance Method Summary (collapse)
-
- ({String => String}) to_rack
Generate the Rack enivronment equivalent of the Request.
Instance Attribute Details
- ({String => String}) rack_env
The Rack environment of the Request
47 48 49 |
# File 'lib/webbed/helpers/rack_request_helper.rb', line 47 def rack_env @rack_env end |
Instance Method Details
- ({String => String}) to_rack
Generate the Rack enivronment equivalent of the Request.
If the Request was created with an environment, the generated environment will be merged with the original environment. The original will not be modified.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/webbed/helpers/rack_request_helper.rb', line 56 def to_rack env = rack_env ? rack_env.dup : {} env['REQUEST_METHOD'] = method.to_s env['PATH_INFO'] = request_uri.path env['QUERY_STRING'] = request_uri.query env['HTTP_VERSION'] = http_version.to_s env['rack.url_scheme'] = scheme env['rack.input'] = entity_body rack_headers = headers.dup env['CONTENT_TYPE'] = rack_headers.delete('Content-Type') env['CONTENT_LENGTH'] = rack_headers.delete('Content-Length') rack_headers.each do |header, value| header = header.upcase.gsub('-', '_') env["HTTP_#{header}"] = value end env end |