Honor a Content-Location header given in a 200 OK response

This commit is contained in:
Mark Paschal 2010-05-21 16:54:20 -07:00
Родитель 95b43c171a
Коммит c477fc6818
1 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -72,6 +72,13 @@ class HttpObject(DataObject):
httplib.CREATED: 'Location',
httplib.MOVED_PERMANENTLY: 'Location',
httplib.FOUND: 'Location',
httplib.OK: 'Content-Location',
}
location_header_required = {
httplib.CREATED: True,
httplib.MOVED_PERMANENTLY: True,
httplib.FOUND: True,
}
content_types = ('application/json',)
@ -217,7 +224,7 @@ class HttpObject(DataObject):
except KeyError:
pass
else:
if location_header.lower() not in response:
if cls.location_header_required.get(response.status) and location_header.lower() not in response:
raise cls.BadResponse(
"%r header missing from %d %s response requesting %s %s"
% (location_header, response.status, response.reason,