Skip to content

Commit

Permalink
[ruby/rack] Don't set redundant Content-Length header (#9015)
Browse files Browse the repository at this point in the history
This header already gets set by all servers except Unicorn.
  • Loading branch information
p8 committed Jun 13, 2024
1 parent 4a164f7 commit dcbfae8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions frameworks/Ruby/rack/hello_world.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ def initialize
end

def respond(content_type, body = '')
headers = {
CONTENT_TYPE => content_type,
DATE => Time.now.utc.httpdate,
SERVER => SERVER_STRING
}
headers[CONTENT_LENGTH] = body.bytesize.to_s if defined?(Unicorn)
[
200,
{
CONTENT_TYPE => content_type,
DATE => Time.now.utc.httpdate,
SERVER => SERVER_STRING,
CONTENT_LENGTH => body.bytesize.to_s
},
headers,
[body]
]
end
Expand Down

0 comments on commit dcbfae8

Please sign in to comment.