diff --git a/lib/grape/dsl/inside_route.rb b/lib/grape/dsl/inside_route.rb index cc56a72d21..bcfd3e84c8 100644 --- a/lib/grape/dsl/inside_route.rb +++ b/lib/grape/dsl/inside_route.rb @@ -329,7 +329,7 @@ def stream(value = nil) return if value.nil? && @stream.nil? header Rack::CONTENT_LENGTH, nil - header Rack::TRANSFER_ENCODING, nil + header Grape::Http::Headers::TRANSFER_ENCODING, nil header Rack::CACHE_CONTROL, 'no-cache' # Skips ETag generation (reading the response up front) if value.is_a?(String) file_body = Grape::ServeStream::FileBody.new(value) diff --git a/lib/grape/http/headers.rb b/lib/grape/http/headers.rb index a9cd7d1ee5..a7e5984f75 100644 --- a/lib/grape/http/headers.rb +++ b/lib/grape/http/headers.rb @@ -12,13 +12,15 @@ module Headers QUERY_STRING = 'QUERY_STRING' if Grape.lowercase_headers? - ALLOW = 'allow' - LOCATION = 'location' - X_CASCADE = 'x-cascade' + ALLOW = 'allow' + LOCATION = 'location' + TRANSFER_ENCODING = 'transfer-encoding' + X_CASCADE = 'x-cascade' else - ALLOW = 'Allow' - LOCATION = 'Location' - X_CASCADE = 'X-Cascade' + ALLOW = 'Allow' + LOCATION = 'Location' + TRANSFER_ENCODING = 'Transfer-Encoding' + X_CASCADE = 'X-Cascade' end GET = 'GET' diff --git a/spec/grape/api_spec.rb b/spec/grape/api_spec.rb index 39dc9df4d4..161b561cbb 100644 --- a/spec/grape/api_spec.rb +++ b/spec/grape/api_spec.rb @@ -1260,7 +1260,7 @@ class DummyFormatClass expect(last_response.headers[Rack::CONTENT_TYPE]).to eq('text/plain') expect(last_response.headers[Rack::CONTENT_LENGTH]).to be_nil expect(last_response.headers[Rack::CACHE_CONTROL]).to eq('no-cache') - expect(last_response.headers[Rack::TRANSFER_ENCODING]).to eq('chunked') + expect(last_response.headers[Grape::Http::Headers::TRANSFER_ENCODING]).to eq('chunked') expect(last_response.body).to eq("c\r\nThis is some\r\nd\r\n file content\r\n0\r\n\r\n") end diff --git a/spec/grape/dsl/inside_route_spec.rb b/spec/grape/dsl/inside_route_spec.rb index 551a3ca193..931382e48c 100644 --- a/spec/grape/dsl/inside_route_spec.rb +++ b/spec/grape/dsl/inside_route_spec.rb @@ -265,7 +265,7 @@ def initialize before do subject.header Rack::CACHE_CONTROL, 'cache' subject.header Rack::CONTENT_LENGTH, 123 - subject.header Rack::TRANSFER_ENCODING, 'base64' + subject.header Grape::Http::Headers::TRANSFER_ENCODING, 'base64' end it 'sends no deprecation warnings' do @@ -295,7 +295,7 @@ def initialize it 'does not change the Transfer-Encoding header' do subject.sendfile file_path - expect(subject.header[Rack::TRANSFER_ENCODING]).to eq 'base64' + expect(subject.header[Grape::Http::Headers::TRANSFER_ENCODING]).to eq 'base64' end end @@ -326,7 +326,7 @@ def initialize before do subject.header Rack::CACHE_CONTROL, 'cache' subject.header Rack::CONTENT_LENGTH, 123 - subject.header Rack::TRANSFER_ENCODING, 'base64' + subject.header Grape::Http::Headers::TRANSFER_ENCODING, 'base64' end it 'emits no deprecation warnings' do @@ -362,7 +362,7 @@ def initialize it 'sets Transfer-Encoding header to nil' do subject.stream file_path - expect(subject.header[Rack::TRANSFER_ENCODING]).to be_nil + expect(subject.header[Grape::Http::Headers::TRANSFER_ENCODING]).to be_nil end end @@ -376,7 +376,7 @@ def initialize before do subject.header Rack::CACHE_CONTROL, 'cache' subject.header Rack::CONTENT_LENGTH, 123 - subject.header Rack::TRANSFER_ENCODING, 'base64' + subject.header Grape::Http::Headers::TRANSFER_ENCODING, 'base64' end it 'emits no deprecation warnings' do @@ -406,7 +406,7 @@ def initialize it 'sets Transfer-Encoding header to nil' do subject.stream stream_object - expect(subject.header[Rack::TRANSFER_ENCODING]).to be_nil + expect(subject.header[Grape::Http::Headers::TRANSFER_ENCODING]).to be_nil end end diff --git a/spec/integration/rack/v2/headers_spec.rb b/spec/integration/rack/v2/headers_spec.rb index 5a915f63a2..4819f21dc1 100644 --- a/spec/integration/rack/v2/headers_spec.rb +++ b/spec/integration/rack/v2/headers_spec.rb @@ -3,5 +3,6 @@ describe Grape::Http::Headers do it { expect(described_class::ALLOW).to eq('Allow') } it { expect(described_class::LOCATION).to eq('Location') } + it { expect(described_class::TRANSFER_ENCODING).to eq('Transfer-Encoding') } it { expect(described_class::X_CASCADE).to eq('X-Cascade') } end diff --git a/spec/integration/rack/v3/headers_spec.rb b/spec/integration/rack/v3/headers_spec.rb index 0796b23616..3be2c1e28b 100644 --- a/spec/integration/rack/v3/headers_spec.rb +++ b/spec/integration/rack/v3/headers_spec.rb @@ -3,5 +3,6 @@ describe Grape::Http::Headers do it { expect(described_class::ALLOW).to eq('allow') } it { expect(described_class::LOCATION).to eq('location') } + it { expect(described_class::TRANSFER_ENCODING).to eq('transfer-encoding') } it { expect(described_class::X_CASCADE).to eq('x-cascade') } end