Creating an HTTP POST request with header information using Net :: HTTP in Ruby

I am trying to programmatically publish an html form on the Internet. I managed to create a request with parameters in the request body, but I can’t figure out how to pass the Http header attributes using the Net :: Http library, Any ideas if this is possible? ... Any other library that does this for me?

res = Net::HTTP.post_form(URI.parse('http://test.com/add_comment'), {'static'=>'1', 'entry_id'=>'23942',}) 
+4
source share
1 answer

check out http://snippets.dzone.com/posts/show/6727

especially strings like:

 req = Net::HTTP::Get.new(url.path) req.add_field("X-Forwarded-For", "0.0.0.0") 
+6
source

Source: https://habr.com/ru/post/1301657/


All Articles