Skip to content

Commit dcbfae8

Browse files
authored
[ruby/rack] Don't set redundant Content-Length header (#9015)
This header already gets set by all servers except Unicorn.
1 parent 4a164f7 commit dcbfae8

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

frameworks/Ruby/rack/hello_world.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,15 @@ def initialize
6565
end
6666

6767
def respond(content_type, body = '')
68+
headers = {
69+
CONTENT_TYPE => content_type,
70+
DATE => Time.now.utc.httpdate,
71+
SERVER => SERVER_STRING
72+
}
73+
headers[CONTENT_LENGTH] = body.bytesize.to_s if defined?(Unicorn)
6874
[
6975
200,
70-
{
71-
CONTENT_TYPE => content_type,
72-
DATE => Time.now.utc.httpdate,
73-
SERVER => SERVER_STRING,
74-
CONTENT_LENGTH => body.bytesize.to_s
75-
},
76+
headers,
7677
[body]
7778
]
7879
end

0 commit comments

Comments
 (0)