How to access *incoming* headers in Sinatra?

那年仲夏 提交于 2019-12-19 09:44:52

问题


I'm sending a request to a Sinatra application by this:

curl -X POST --header "MyHeader: 123444" http://localhost:9292/test -d ""

How can I access it in the route? These don't work:

 headers["MyHeader"]
 request["MyHeader"]
 request.env["MyHeader"]

They're all nil.


回答1:


Have you tried adding HTTP to the header name? So it would be request.env["HTTP_ MyHeader"] This is part of the rack spec.



来源:https://stackoverflow.com/questions/35787395/how-to-access-incoming-headers-in-sinatra

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!