Merge pull request #843 from yunstanford/case-insensitive-check
Case insensitive check
This commit is contained in:
		| @@ -238,15 +238,15 @@ def parse_multipart_form(body, boundary): | ||||
|                 break | ||||
|  | ||||
|             colon_index = form_line.index(':') | ||||
|             form_header_field = form_line[0:colon_index] | ||||
|             form_header_field = form_line[0:colon_index].lower() | ||||
|             form_header_value, form_parameters = parse_header( | ||||
|                 form_line[colon_index + 2:]) | ||||
|  | ||||
|             if form_header_field == 'Content-Disposition': | ||||
|             if form_header_field == 'content-disposition': | ||||
|                 if 'filename' in form_parameters: | ||||
|                     file_name = form_parameters['filename'] | ||||
|                 field_name = form_parameters.get('name') | ||||
|             elif form_header_field == 'Content-Type': | ||||
|             elif form_header_field == 'content-type': | ||||
|                 file_type = form_header_value | ||||
|  | ||||
|         post_data = form_part[line_index:-4] | ||||
|   | ||||
| @@ -259,20 +259,26 @@ def test_post_form_urlencoded(): | ||||
|  | ||||
|     assert request.form.get('test') == 'OK' | ||||
|  | ||||
|  | ||||
| def test_post_form_multipart_form_data(): | ||||
| @pytest.mark.parametrize( | ||||
|     'payload', [ | ||||
|         '------sanic\r\n' \ | ||||
|         'Content-Disposition: form-data; name="test"\r\n' \ | ||||
|         '\r\n' \ | ||||
|         'OK\r\n' \ | ||||
|         '------sanic--\r\n', | ||||
|         '------sanic\r\n' \ | ||||
|         'content-disposition: form-data; name="test"\r\n' \ | ||||
|         '\r\n' \ | ||||
|         'OK\r\n' \ | ||||
|         '------sanic--\r\n', | ||||
|     ]) | ||||
| def test_post_form_multipart_form_data(payload): | ||||
|     app = Sanic('test_post_form_multipart_form_data') | ||||
|  | ||||
|     @app.route('/', methods=['POST']) | ||||
|     async def handler(request): | ||||
|         return text('OK') | ||||
|  | ||||
|     payload = '------sanic\r\n' \ | ||||
|               'Content-Disposition: form-data; name="test"\r\n' \ | ||||
|               '\r\n' \ | ||||
|               'OK\r\n' \ | ||||
|               '------sanic--\r\n' | ||||
|  | ||||
|     headers = {'content-type': 'multipart/form-data; boundary=----sanic'} | ||||
|  | ||||
|     request, response = app.test_client.post(data=payload, headers=headers) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Raphael Deem
					Raphael Deem