#402 new
seph

webrat mechanize doesn't support custom headers

Reported by seph | January 4th, 2011 @ 11:12 AM

webrat mechanize doesn't use the headers array in get or post. There's no reason it can't. I rewrote things as:

class Webrat::MechanizeAdapter
  def get(url, data, headers =  nil)
    @response = mechanize.get( { :url => url, :headers => headers }, data)
  end

    def post(url, data, headers = nil)
      post_data = data.inject({}) do |memo, param|
        case param
        when Hash
          param.each {|attribute, value| memo[attribute] = value }
          memo
        when Array
          case param.last
          when Hash
            param.last.each {|attribute, value| memo["#{param.first}[#{attribute}]"] = value }
          else
            memo[param.first] = param.last
          end
          memo
        end
      end
      @response = mechanize.post(url, post_data, headers)
    end
end

Comments and changes to this ticket

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

People watching this ticket

Pages