From ca7c4dc0e8cc00313248a40c400aa9a5cd42b454 Mon Sep 17 00:00:00 2001 From: Serdar Dogruyol Date: Sun, 19 Nov 2017 18:14:06 +0300 Subject: [PATCH] Parse body in multipart forms --- src/kemal/param_parser.cr | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/kemal/param_parser.cr b/src/kemal/param_parser.cr index d2893cb..e210873 100644 --- a/src/kemal/param_parser.cr +++ b/src/kemal/param_parser.cr @@ -43,14 +43,8 @@ module Kemal private def parse_body content_type = @request.content_type return unless content_type - if content_type.try(&.starts_with?(URL_ENCODED_FORM)) - @body = parse_part(@request.body) - return - end - if content_type.try(&.starts_with?(MULTIPART_FORM)) - parse_file_upload - return - end + @body = parse_part(@request.body) if content_type.starts_with?(URL_ENCODED_FORM) + parse_file_upload if content_type.starts_with?(MULTIPART_FORM) end private def parse_query @@ -75,6 +69,7 @@ module Kemal @body[upload.name] = upload.body.gets_to_end end end + @body = parse_part(@request.body) end # Parses JSON request body if Content-Type is `application/json`.