Ruby mechanize post with header

前端 未结 4 463
梦如初夏
梦如初夏 2021-02-04 14:14

I have page with js that post data via XMLHttpRequest and server side script check for this header, how to send this header?

agent = WWW::Mechanize.new { |a|
  a         


        
4条回答
  •  说谎
    说谎 (楼主)
    2021-02-04 14:39

    Seems like earlier that lambda had one argument, but now it has two:

    agent = Mechanize.new do |agent|
      agent.pre_connect_hooks << lambda do |agent, request|
        request["Accept-Language"] = "ru"
      end
    end
    

提交回复
热议问题