简体   繁体   中英

how to disable WEBrick Server header

I've developed a web application in Ruby (using Sinatra framework if that matters).

It adds a Server header to every HTTP response:

Server: WEBrick/1.3.1 (Ruby/1.9.3/2011-09-23)

How do I disable it?

I'm not sure that you can delete Server header at all without hacking the guts. I think that more simple is delete all content of this header such way:

require 'sinatra'

set :server, 'WEBrick'

get '/' do
  headers "Server" => ""
  "Hello, World!"
end

If you want to prepare this manipulation for each action, you can use before filter:

require 'sinatra'

set :server, 'WEBrick'

before do
  headers "Server" => ""
end

get '/' do
  "Hello, World!"
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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