Ability to optionally disable powered-by header (#449)

This commit is contained in:
Blacksmoke16 2018-05-09 03:19:59 -04:00 committed by Serdar Dogruyol
parent 73045bb138
commit f3f7e319ae
4 changed files with 16 additions and 1 deletions

View file

@ -22,6 +22,7 @@ module Kemal
property always_rescue, server : HTTP::Server?, extra_options, shutdown_message
property serve_static : (Bool | Hash(String, Bool))
property static_headers : (HTTP::Server::Response, String, File::Stat -> Void)?
property powered_by_header : Bool = true
def initialize
@host_binding = "0.0.0.0"

View file

@ -7,7 +7,7 @@ module Kemal
INSTANCE = new
def call(context : HTTP::Server::Context)
context.response.headers.add "X-Powered-By", "Kemal"
context.response.headers.add "X-Powered-By", "Kemal" if Kemal.config.powered_by_header
context.response.content_type = "text/html" unless context.response.headers.has_key?("Content-Type")
call_next context
end