Sinatra on Thin: How to hide or change HTTP 'Server' response header

rack, sinatra, thin

Solution

This works here:

require 'sinatra'

get '/' do
  [200, {'Server' => 'My Server'}, 'contents']
end

If you want to do it for all requests:

class ChangeServer
  def initialize(app)
    @app = app
  end

  def call(env)
    res = @app.call(env)
    res[1]['Server'] = 'My server'
    return res
  end
end

And then you `use ChangeServer` in your app.

Problem

What is the cleanest way to do this? Some Rack middleware? I tried to modify `env['SERVER_SOFTWARE']` but I still get in response: ``` Server: thin 1.3.1 codename Triple Espresso ``` How to change the value of that header, or remove it completetly from response? EDIT Another try: ``` before do headers 'Server' => 'ipm' end after do headers 'Server' => 'ipm' end ``` But still no changes.

Original source