File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -165,14 +165,25 @@ def is_content_json(req):
165
165
:param req: the request
166
166
:return: bool
167
167
"""
168
+
169
+ # Attempt to get the content type from the request.
168
170
content_type = ''
169
171
try :
170
172
content_type = req .content_type
171
173
except AttributeError :
172
174
content_type = req .environ .get (['CONTENT_TYPE' ], '' )
175
+
176
+ # Attempt to get the content length from the request.
177
+ # Extra care for symlinks in swift pointing to a json file and having
178
+ # the content type header set accordingly without having a content_length.
179
+ content_length = 0
180
+ try :
181
+ content_length = int (req .content_length )
182
+ except (AttributeError , TypeError ):
183
+ pass
173
184
finally :
174
185
return 'application/json' in content_type \
175
- and int ( req . content_length ) > 0
186
+ and content_length > 0
176
187
177
188
178
189
def is_uid_string (string ):
You can’t perform that action at this time.
0 commit comments