title: How to override a method of ruby lib?
body: <p>When I use ruby 1.8.7 Net::HTTP.post_form(URI.parse(URL), params), I found it has a bug, see :</p>
  
  <p><a href="https://stackoverflow.com/questions/3214502/how-to-send-an-array-with-nethttp-post-form">https://stackoverflow.com/questions/3214502/how-to-send-an-array-with-nethttp-post-form</a></p>
  
  <p>My code is a regular ruby script, and I want to override that method(<code>net/http.rb#set_form_data</code>) like this:</p>
  
  <pre><code>require 'net/http'
  require 'uri'
  
  module Net
    module HTTPHeader
      def set_form_data(params, sep = '&amp;')
        params_array = params.map do |k,v|
          v.inject([]){|c, val| c &lt;&lt; "#{urlencode(k.to_s)}=#{urlencode(val.to_s)}"}.join(sep)
        end
        self.body = params_array.join(sep)
        self.content_type = 'application/x-www-form-urlencoded'
      end
    end
  end
  
  res = Net::HTTP.post_form(URI.parse(URL),
                   {'type'=&gt;'flowers',
                    'colors[]' =&gt; %w[red white blue] })
  </code></pre>
  
  <p>But it seems my <code>set_form_data</code> method has not been invoked(I debuged). Is there anything wrong in my code?</p>