Sha256: 5ed126a1aa77252b3bfee6b237a4f961fa29839cfd54b602b5658710f559688e

Contents?: true

Size: 725 Bytes

Versions: 4

Compression:

Stored size: 725 Bytes

Contents

class Mechanize
  class Chain
    class RequestResolver
      include Mechanize::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
            def path
              uri.path
            end
            def each_header; end
          end
          params[:request] ||= o
        end

        super
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 4 rubygems

Version Path
kitamomonga-mechanize-0.9.3.20090724215219 lib/mechanize/chain/request_resolver.rb
tenderlove-mechanize-0.9.3.20090911221705 lib/mechanize/chain/request_resolver.rb
domo-0.0.4 vendor/bundle/ruby/1.9.1/gems/mechanize-1.0.0/lib/mechanize/chain/request_resolver.rb
mechanize-1.0.0 lib/mechanize/chain/request_resolver.rb