Treat body as IO in param_parser (#252)

This commit is contained in:
Serdar Dogruyol 2016-11-16 22:09:50 +04:00 committed by GitHub
parent 012ac8f6b7
commit bc764b7af7

View file

@ -64,7 +64,7 @@ module Kemal
def parse_json def parse_json
return unless @request.body && @request.headers["Content-Type"]?.try(&.starts_with?(APPLICATION_JSON)) return unless @request.body && @request.headers["Content-Type"]?.try(&.starts_with?(APPLICATION_JSON))
body = @request.body.as(String) body = @request.body.to_s
case json = JSON.parse(body).raw case json = JSON.parse(body).raw
when Hash when Hash
json.each do |key, value| json.each do |key, value|
@ -76,7 +76,7 @@ module Kemal
end end
def parse_part(part) def parse_part(part)
HTTP::Params.parse(part || "") HTTP::Params.parse(part.to_s || "")
end end
end end
end end