Skip to content

Commit a5703ff

Browse files
authored
[ruby/roda-sequel] Only set headers not created by servers (#9571)
Servers like Iodine sets the `Date` header itself. +------------------------------------+------+-----+-----+------+-------+---------+--------------+ | branch_name| json| db|query|update|fortune|plaintext|weighted_score| +------------------------------------+------+-----+-----+------+-------+---------+--------------+ | master|213942|52774|37141| 22971| 49660| 227545| 2923| |roda-sequel/remove-redundant-headers|280527|89348|61538| 24688| 57966| 335448| 3752| +------------------------------------+------+-----+-----+------+-------+---------+--------------+
1 parent 8ff228e commit a5703ff

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

frameworks/Ruby/roda-sequel/hello_world.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,19 @@ def rand1
1515
rand(MAX_PK) + 1
1616
end
1717

18+
if defined?(Puma)
19+
def set_default_headers(response)
20+
response[DATE_HEADER] = Time.now.httpdate
21+
response[SERVER_HEADER] = SERVER_STRING
22+
end
23+
else
24+
def set_default_headers(response)
25+
response[SERVER_HEADER] = SERVER_STRING
26+
end
27+
end
28+
1829
route do |r|
19-
response[DATE_HEADER] = Time.now.httpdate
20-
response[SERVER_HEADER] = SERVER_STRING if SERVER_STRING
30+
set_default_headers(response)
2131

2232
# Test type 1: JSON serialization
2333
r.is "json" do

0 commit comments

Comments
 (0)