Mario
Mario

Reputation: 185

How to access *incoming* headers in Sinatra?

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.

Upvotes: 3

Views: 2164

Answers (1)

Chorkpop
Chorkpop

Reputation: 96

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

Upvotes: 8

Related Questions