在rails中将请求添加到请求中 [英] Add headers to a request in rails

查看:96
本文介绍了在rails中将请求添加到请求中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要添加 X-FORWARDED 使用Rails 3.2.1创建HTTP Post。 c> FOR标题。如何在Rails中做到这一点?



代码:

  post_data = {
username=> tabuser
}

response = Net :: HTTP.post_form(URI.parse(http://< my php file>),post_data)

谢谢

解决方案

:: http示例可能有帮助吗?



https:/ /github.com/augustl/net-http-cheat-sheet/blob/master/headers.rb


I'm using Rails 3.2.1 to make an HTTP Post.

I need to add X-FORWARDED FOR to the header. How do I do that in Rails?

Code:

post_data = {
  "username" => tabuser
}

response = Net::HTTP.post_form(URI.parse("http://<my php file>"), post_data)

Thanks

解决方案

These net::http examples might be helpful?

https://github.com/augustl/net-http-cheat-sheet/blob/master/headers.rb

这篇关于在rails中将请求添加到请求中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆