开发者

Creating an HTTP POST Request with Header info using Net::HTTP in Ruby

开发者 https://www.devze.com 2022-12-20 07:27 出处:网络
Im trying to programmatically post to an html form on the internet.I have managed to create a request with parameters in the request body but I can\'t figure out how to pass in Http Header attr开发者_

Im trying to programmatically post to an html form on the internet.I have managed to create a request with parameters in the request body but I can't figure out how to pass in Http Header attr开发者_C百科ibutes using the Net::Http library. Any ideas if this is possible?... Any other library that would do it for me ?

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


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

especially lines like:

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

精彩评论

暂无评论...
验证码 换一张
取 消