Accessing headers from Sinatra

前端 未结 2 512
滥情空心
滥情空心 2021-02-08 06:00

I am trying to access the headers in a filter in sinatra. My request includes the header \"HTTP_AUTH\", however I can\'t access it. My filter is

before do
    ha         


        
2条回答
  •  误落风尘
    2021-02-08 06:18

    Try use before block with headers method:

    before do
      headers "HTTP_AUTH" => "test"
      headers "Content-Type" => "text/html; charset=utf-8"
    end
    

    or in request:

    get '/' do
      headers['HTTP_AUTH'] = "test"
      headers['Cache-Control'] = 'public, max-age=600'
      puts headers # show headers on this request
    end
    

    Use headers with is just hash

提交回复
热议问题