title: Save a file with ruby mechanize
body: <p>I have a problem with code (this code may to get request &amp; download generated file):</p>
  
  <pre><code>require 'rubygems'
  require 'mechanize'
  require 'hpricot'
  
  OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
  
  user = "xxx"
  pass = "xxx"
  auth_key = "xxx"
  ip = "xxx"
  
  agent = Mechanize.new
  page = agent.get("https://#{ip}/cgi-bin/welcome.cgi")
  form = page.forms.first
  form.username = user
  form.password = Digest::MD5.hexdigest(pass + auth_key)
  page = agent.submit form
  
  page = agent.get("https://#{ip}/cgi-bin/config.exp")
  form = page.forms.first
  agent.pluggable_parser.default = Mechanize::FileSaver
  agent.post("https://#{ip}/cgi-bin/config.exp", {"submitstatus" =&gt; "1"})
  </code></pre>
  
  <p>With this I have a error:</p>
  
  <pre><code>/var/lib/gems/1.8/gems/mechanize-2.4/lib/mechanize/http/agent.rb:291:in `fetch': 400 =&gt; Net::HTTPBadRequest for https://31.223.225.133/cgi-bin/config.exp -- unhandled response (Mechanize::ResponseCodeError)
   from /var/lib/gems/1.8/gems/mechanize-2.4/lib/mechanize.rb:407:in `get'
   from /home/lord/Dropbox/work/ruby/ruby_backup/backup.ru:22
  </code></pre>
  
  <p>How to simulate this wget request for downloading file:</p>
  
  <pre><code> `wget --no-check-certificate --load-cookies cookie --post-data='submitstatus=1' \
   --header='Host: 10.1.25.254' \
   --header='User-Agent: Mozilla/5.0' \
   --header='Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
   --header='Accept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3' \
   --header='Accept-Encoding: gzip, deflate' \
   --header='Connection: keep-alive' \
   --header='Referer: https://10.1.25.254/sys_setting.htm' \
   --header='Content-Type: application/x-www-form-urlencoded' \
   --header='Content-Length: 14' \
   https://$ip/cgi-bin/config.exp`
  </code></pre>
  
  <p>advance thanks</p>