Skip to content

Commit

Permalink
Don't add content-length header.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jun 11, 2024
1 parent 35b7310 commit e662408
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 0 additions & 1 deletion lib/rack/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ def process_request(uri, env)
close_body(body)
cookie_jar.merge(last_response.headers['set-cookie'], uri)
@after_request.each(&:call)
@last_response.finish

yield @last_response if block_given?

Expand Down
3 changes: 0 additions & 3 deletions spec/fixtures/fake_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ module Test
class FakeApp
def call(env)
_, h, b = res = handle(env)
length = 0
b.each{|s| length += s.bytesize}
h['content-length'] = length.to_s
h['content-type'] = 'text/html;charset=utf-8'
res
end
Expand Down
5 changes: 5 additions & 0 deletions spec/rack/test_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,11 @@ def closed?
last_response['content-type'].must_equal 'text/html;charset=utf-8'
end

it 'should not add a content-length header' do
request '/'
last_response['content-length'].must_be_nil
end

it 'raises an error if no requests have been issued' do
proc do
last_response
Expand Down

0 comments on commit e662408

Please sign in to comment.