Skip to content

Commit 2d6b02b

Browse files
authored
Merge pull request rails#50632 from skipkayhil/hm-move-chunk-test-to-actionpack
Move Transfer-Encoding chunked test to Action Pack
2 parents 3c19732 + a03a854 commit 2d6b02b

File tree

2 files changed

+32
-54
lines changed

2 files changed

+32
-54
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# frozen_string_literal: true
2+
3+
require "stringio"
4+
require "abstract_unit"
5+
6+
class ChunkedTest < ActionDispatch::IntegrationTest
7+
class ChunkedController < ApplicationController
8+
def chunk
9+
render json: {
10+
raw_post: request.raw_post,
11+
content_length: request.content_length
12+
}
13+
end
14+
end
15+
16+
# The TestInput class prevents Rack::MockRequest from adding a Content-Length when the method `size` is defined
17+
class TestInput < StringIO
18+
undef_method :size
19+
end
20+
21+
test "parses request raw_post correctly when request has Transfer-Encoding header without a Content-Length value" do
22+
@app = self.class.build_app
23+
@app.routes.draw do
24+
post "chunked", to: ChunkedController.action(:chunk)
25+
end
26+
27+
post "/chunked", params: TestInput.new("foo=bar"), headers: { "Transfer-Encoding" => "gzip, chunked;foo=bar" }
28+
29+
assert_equal 7, response.parsed_body["content_length"]
30+
assert_equal "foo=bar", response.parsed_body["raw_post"]
31+
end
32+
end

railties/test/railties/http_request_test.rb

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)