Archived
Brother proxy: rewind request body before forwarding (Rack 3 leaves it consumed)
deploy / deploy (push) Successful in 12s
deploy / deploy (push) Successful in 12s
This commit is contained in:
1 parent
fc59cf595e
commit
7dabfb6223
1 file changed
+6
-1
@@ -241,7 +241,12 @@ helpers do
|
|||||||
proxied['Content-Type'] = request.content_type if request.content_type
|
proxied['Content-Type'] = request.content_type if request.content_type
|
||||||
proxied['X-Forwarded-Prefix'] = prefix
|
proxied['X-Forwarded-Prefix'] = prefix
|
||||||
proxied['X-Forwarded-Host'] = request.host
|
proxied['X-Forwarded-Host'] = request.host
|
||||||
proxied.body = request.body.read unless request.request_method == 'GET'
|
# Sinatra already consumed the body when parsing params (Rack 3 no longer
|
||||||
|
# rewinds it), so rewind first or form POSTs reach brother_ql_web empty.
|
||||||
|
unless request.request_method == 'GET'
|
||||||
|
request.body.rewind
|
||||||
|
proxied.body = request.body.read
|
||||||
|
end
|
||||||
|
|
||||||
res = Net::HTTP.start(uri.host, uri.port) { |http| http.request(proxied) }
|
res = Net::HTTP.start(uri.host, uri.port) { |http| http.request(proxied) }
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user