Skip to content

Commit d25351f

Browse files
authored
Make response headers compliant with Rack 3 specification (#73)
1 parent e814208 commit d25351f

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

lib/rack/dev-mark/middleware.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def call(env)
2020

2121
read_headers = defined?(Rack::Headers) ? Rack::Headers.new(headers) : HeaderHash.new(headers)
2222

23-
headers['X-Rack-Dev-Mark-Env'] = CGI.escape Rack::DevMark.env
23+
headers['x-rack-dev-mark-env'] = CGI.escape Rack::DevMark.env
2424

2525
redirect = 300 <= status.to_i && status.to_i < 400
2626
if !redirect && !Rack::DevMark.tmp_disabled && read_headers['Content-Type'].to_s =~ %r{\btext/html\b}i
@@ -33,7 +33,7 @@ def call(env)
3333
end
3434
end
3535
response.close if response.respond_to?(:close)
36-
headers['Content-Length'] = new_body.bytesize.to_s if read_headers['Content-Length']
36+
headers['content-length'] = new_body.bytesize.to_s if read_headers['Content-Length']
3737
response = [new_body]
3838
end
3939

spec/rack/dev-mark/middleware_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
context "ASCII env string" do
2626
it "adds http headers" do
2727
_, headers, _ = subject.call({})
28-
expect(headers).to include('X-Rack-Dev-Mark-Env' => 'test')
28+
expect(headers).to include('x-rack-dev-mark-env' => 'test')
2929
end
3030
end
3131
context "Non ASCII string" do
3232
let(:env) { 'テスト' }
3333
it "adds http headers" do
3434
_, headers, _ = subject.call({})
35-
expect(headers).to include('X-Rack-Dev-Mark-Env' => '%E3%83%86%E3%82%B9%E3%83%88')
35+
expect(headers).to include('x-rack-dev-mark-env' => '%E3%83%86%E3%82%B9%E3%83%88')
3636
end
3737
end
3838
end

0 commit comments

Comments
 (0)