简体   繁体   English

Rails request.headers无法获取值

[英]rails request.headers cannot get values

I am trying to get some values from the headers in my rails app. 我正在尝试从Rails应用程序的标题中获取一些值。 If I iterate over request.headers like 如果我遍历request.headers喜欢

request.headers.each do |k,v|

I get all the things I need (and much more ;-) ): 我得到了我需要的所有东西(还有更多;-)):

HTTPS: on
HTTP_ACCEPT_ENCODING: gzip, deflate
givenName: MemyselfandI
mail: noone@nowhere.org

However I can only access HTTP-headers like "HTTP_ACCEPT_ENCODING" etc. I cannot access eg mail: 但是,我只能访问HTTP头,例如“ HTTP_ACCEPT_ENCODING”等。我无法访问例如邮件:

request.headers['mail']

is nil. 是零。

Is there anyway to get the values of "mail" and "givenName" etc? 反正有没有获得“邮件”和“ givenName”等值?

Thanks in advance, Sven 预先感谢,斯文

Meanwhile I found the solution: 同时,我找到了解决方案:

request.headers.env['key'] = value

So, to get the value of mail you have to 因此,要获得邮件的价值,您必须

request.headers.env['mail']

All the best, Sven 祝一切顺利,斯文

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM