Use HTTP.format_time method

This commit is contained in:
Sijawusz Pur Rahnama 2024-04-03 17:37:56 +02:00 committed by GitHub
parent a9bd09b122
commit 3f6a4216d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,3 +1,5 @@
require "http"
module Kemal module Kemal
# Initializes the context with default values, such as # Initializes the context with default values, such as
# *Content-Type* or *X-Powered-By* headers. # *Content-Type* or *X-Powered-By* headers.
@ -9,7 +11,7 @@ module Kemal
def call(context : HTTP::Server::Context) def call(context : HTTP::Server::Context)
context.response.headers.add "X-Powered-By", "Kemal" if Kemal.config.powered_by_header? 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") context.response.content_type = "text/html" unless context.response.headers.has_key?("Content-Type")
context.response.headers.add "Date", Time.utc.to_rfc2822 context.response.headers.add "Date", HTTP.format_time(Time.utc)
call_next context call_next context
end end
end end