Skip to content

Commit 16fbe7f

Browse files
committed
fix swift symlink to json file
1 parent 4a24531 commit 16fbe7f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

watcher/common.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,25 @@ def is_content_json(req):
165165
:param req: the request
166166
:return: bool
167167
"""
168+
169+
# Attempt to get the content type from the request.
168170
content_type = ''
169171
try:
170172
content_type = req.content_type
171173
except AttributeError:
172174
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
173184
finally:
174185
return 'application/json' in content_type \
175-
and int(req.content_length) > 0
186+
and content_length > 0
176187

177188

178189
def is_uid_string(string):

0 commit comments

Comments
 (0)