lib/plezi/base/rack_app.rb in plezi-0.7.5 vs lib/plezi/base/rack_app.rb in plezi-0.7.6
- old
+ new
@@ -13,16 +13,16 @@
def call env
raise "No Plezi Services" unless Plezi::SERVICES[0]
Object.const_set('PLEZI_ON_RACK', true) unless defined? PLEZI_ON_RACK
# re-encode to utf-8, as it's all BINARY encoding at first
- env["rack.input"].rewind
- env['rack.input'] = StringIO.new env["rack.input"].read.encode("utf-8", "binary", invalid: :replace, undef: :replace, replace: '')
+ env['rack.input'].rewind
+ env['rack.input'] = StringIO.new env['rack.input'].read.encode('utf-8', 'binary', invalid: :replace, undef: :replace, replace: '')
env.each do |k, v|
if k.to_s.match /^[A-Z]/
if v.is_a?(String) && !v.frozen?
- v.force_encoding("binary").encode!("utf-8", "binary", invalid: :replace, undef: :replace, replace: '') unless v.force_encoding("utf-8").valid_encoding?
+ v.force_encoding('binary').encode!('utf-8', 'binary', invalid: :replace, undef: :replace, replace: '') unless v.force_encoding('utf-8').valid_encoding?
end
end
end
# re-key params
# new_params = {}
@@ -31,15 +31,15 @@
# make hashes magical
make_hash_accept_symbols(env)
# use Plezi Cookies
- env["rack.request.cookie_string"] = env["HTTP_COOKIE"]
- env["rack.request.cookie_hash"] = Plezi::Cookies.new.update(env["rack.request.cookie_hash"] || {})
+ env['rack.request.cookie_string'] = env['HTTP_COOKIE']
+ env['rack.request.cookie_hash'] = Plezi::Cookies.new.update(env['rack.request.cookie_hash'] || {})
# chomp path
- env["PATH_INFO"].chomp! '/'
+ env['PATH_INFO'].chomp! '/'
# get response
response = Plezi::SERVICES[0][1][:handler].call env
return response if response.is_a?(Array)
@@ -49,11 +49,11 @@
headers = response.headers
# set cookie headers
headers.delete 'transfer-encoding'
headers.delete 'connection'
unless response.cookies.empty?
- headers["Set-Cookie"] = []
- response.cookies.each {|k,v| headers["Set-Cookie"] << ("#{k.to_s}=#{v.to_s}")}
+ headers['Set-Cookie'] = []
+ response.cookies.each {|k,v| headers['Set-Cookie'] << ("#{k.to_s}=#{v.to_s}")}
end
[response.status, headers, response.body]
end
end
\ No newline at end of file