# HG changeset patch # User neko259 # Date 2015-07-09 10:46:31 # Node ID 388a3537d7ce6492a90f75e94e4390af6ff37157 # Parent 67c0d00037e86a8227ecead6b9ad9acd6dc40b84 Load images with image/jpg mimetype diff --git a/boards/forms.py b/boards/forms.py --- a/boards/forms.py +++ b/boards/forms.py @@ -15,9 +15,12 @@ from boards.models import Tag, Post from neboard import settings import boards.settings as board_settings +HEADER_CONTENT_LENGTH = 'content-length' +HEADER_CONTENT_TYPE = 'content-type' CONTENT_TYPE_IMAGE = ( 'image/jpeg', + 'image/jpg', 'image/png', 'image/gif', 'image/bmp', @@ -298,9 +301,9 @@ class PostForm(NeboardForm): try: # Verify content headers response_head = requests.head(url, verify=False) - content_type = response_head.headers['content-type'].split(';')[0] + content_type = response_head.headers[HEADER_CONTENT_TYPE].split(';')[0] if content_type in CONTENT_TYPE_IMAGE: - length_header = response_head.headers.get('content-length') + length_header = response_head.headers.get(HEADER_CONTENT_LENGTH) if length_header: length = int(length_header) self.validate_image_size(length)