Sha256: d08ed2017abce631d4c46da126aac9ec7e9da16cd6b684b157728803f8c00ee4

Contents?: true

Size: 687 Bytes

Versions: 5

Compression:

Stored size: 687 Bytes

Contents

module WWW
  class Mechanize
    class Chain
      class RequestResolver
        include WWW::Handler

        def handle(ctx, params)
          uri = params[:uri]
          if %w{ http https }.include?(uri.scheme.downcase)
            klass = Net::HTTP.const_get(params[:verb].to_s.capitalize)
            params[:request] ||= klass.new(uri.request_uri)
          end

          if %w{ file }.include?(uri.scheme.downcase)
            o = Struct.new(:uri).new(uri)
            class << o
              def add_field(*args); end
              alias :[]= :add_field
            end
            params[:request] ||= o
          end

          super
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mechanize-0.8.0 lib/www/mechanize/chain/request_resolver.rb
mechanize-0.8.1 lib/www/mechanize/chain/request_resolver.rb
mechanize-0.8.2 lib/www/mechanize/chain/request_resolver.rb
mechanize-0.8.3 lib/www/mechanize/chain/request_resolver.rb
mechanize-0.8.4 lib/www/mechanize/chain/request_resolver.rb