From 788253cbe8e2da5d0b5756885f74b49b00195363 Mon Sep 17 00:00:00 2001 From: Dirk Guijt Date: Fri, 2 Feb 2018 00:55:51 +0100 Subject: [PATCH] changes based on discussion on PR #1109 --- sanic/request.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sanic/request.py b/sanic/request.py index 98bb049f..33844cd7 100644 --- a/sanic/request.py +++ b/sanic/request.py @@ -303,13 +303,11 @@ def parse_multipart_form(body, boundary): form_line[colon_index + 2:]) if form_header_field == 'content-disposition': - if 'filename' in form_parameters: - file_name = form_parameters['filename'] - field_name = form_parameters['name'] + file_name = form_parameters.get('filename') + field_name = form_parameters.get('name') elif form_header_field == 'content-type': content_type = form_header_value - if 'charset' in form_parameters: - content_charset = form_parameters['charset'] + content_charset = form_parameters.get('charset', 'utf-8') post_data = form_part[line_index:-4] if file_name: