Skip to content

Commit 7bbded6

Browse files
committed
handle case where request body is a Rack::Lint::InputWrapper
1 parent 77a21ee commit 7bbded6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/rack/reverse_proxy.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ def call(env)
4444
when "PUT", "POST"
4545
req = Net::HTTP.const_get(m.capitalize).new(uri.request_uri, headers)
4646
req.basic_auth all_opts[:username], all_opts[:password] if all_opts[:username] and all_opts[:password]
47-
req.content_length = rackreq.body.size
47+
48+
if rackreq.body.respond_to?(:read) && rackreq.body.respond_to?(:rewind)
49+
body = rackreq.body.read
50+
req.content_length = body.size
51+
rackreq.body.rewind
52+
else
53+
req.content_length = rackreq.body.size
54+
end
55+
4856
req.body_stream = rackreq.body
4957
else
5058
raise "method not supported: #{m}"

0 commit comments

Comments
 (0)