Add Date header to HTTP responses (#676)

This commit is contained in:
Sijawusz Pur Rahnama 2024-04-10 18:26:04 +02:00 committed by GitHub
parent 7c47bbc150
commit b074578c1a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 0 deletions

View file

@ -11,6 +11,18 @@ describe "Kemal::InitHandler" do
context.response.headers["Content-Type"].should eq "text/html"
end
it "initializes context with Date header" do
request = HTTP::Request.new("GET", "/")
io = IO::Memory.new
response = HTTP::Server::Response.new(io)
context = HTTP::Server::Context.new(request, response)
Kemal::InitHandler::INSTANCE.next = ->(_context : HTTP::Server::Context) {}
Kemal::InitHandler::INSTANCE.call(context)
date = context.response.headers["Date"]?.should_not be_nil
date = HTTP.parse_time(date).should_not be_nil
date.should be_close(Time.utc, 1.second)
end
it "initializes context with X-Powered-By: Kemal" do
request = HTTP::Request.new("GET", "/")
io = IO::Memory.new