rest protocol detection: test Accept header first; use startswith for Content-Type match

--HG--
branch : json_strictness
This commit is contained in:
Craig McDaniel 2013-01-02 16:57:45 -05:00
parent d5ff7c0893
commit 5380134951

View File

@ -35,7 +35,12 @@ class RestProtocol(Protocol):
for dataformat in self.dataformats:
if request.path.endswith('.' + dataformat):
return True
return request.headers.get('Content-Type') in self.content_types
if request.headers.get('Accept') in self.content_types:
return True
for ct in self.content_types:
if request.headers['Content-Type'].startswith(ct):
return True
return False
def iter_calls(self, request):
context = CallContext(request)