Sha256: c652654178fc51e16b3cb4337a1fe08b7b171b835cc174b5011b1685ef31ce97

Contents?: true

Size: 717 Bytes

Versions: 13

Compression:

Stored size: 717 Bytes

Contents

#
# Rack doesn't works well with ruby 1.9.2
# there's no :each method in String anymore
# 
class Rack::Response
  def each(&callback)
    if @body.is_a? String
      @body.each_char(&callback)
    else
      @body.each(&callback)
    end
    @writer = callback
    @block.call(self)  if @block
  end
end

class Rack::Request
  alias_method :params_with_wrong_encoding, :params
  def params
    @params ||= encode_in_utf8(params_with_wrong_encoding)
  end

  protected
    def encode_in_utf8 hash
      r = {}
      hash.each do |k, v|
        r[k] = if v.is_a? String
          v.force_encoding("UTF-8")
        elsif v.is_a? Hash
          encode_in_utf8(v)
        else
          v
        end
      end
    end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rad_core-0.0.25 lib/rad/http/_support/rack/fixes.rb
rad_core-0.0.24 lib/rad/http/_support/rack/fixes.rb
rad_core-0.0.23 lib/rad/http/_support/rack/fixes.rb
rad_core-0.0.22 lib/rad/http/_support/rack/fixes.rb
rad_core-0.0.21 lib/rad/http/_support/rack/fixes.rb
rad_core-0.0.20 lib/rad/http/_support/rack/fixes.rb
rad_core-0.0.19 lib/rad/http/_support/rack/fixes.rb
rad_core-0.0.18 lib/rad/http/_support/rack/fixes.rb
rad_core-0.0.17 lib/rad/http/_support/rack/fixes.rb
rad_core-0.0.16 lib/rad/http/_support/rack/fixes.rb
rad_core-0.0.15 lib/rad/http/_support/rack/fixes.rb
rad_core-0.0.14 lib/rad/http/_support/rack/fixes.rb
rad_core-0.0.13 lib/rad/http/support/rack/fixes.rb