From 5380134951396af87e93b004780bde14737ac34c Mon Sep 17 00:00:00 2001 From: Craig McDaniel Date: Wed, 2 Jan 2013 16:57:45 -0500 Subject: [PATCH] rest protocol detection: test Accept header first; use startswith for Content-Type match --HG-- branch : json_strictness --- wsme/rest/protocol.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wsme/rest/protocol.py b/wsme/rest/protocol.py index 4b762fc..8d5ecba 100644 --- a/wsme/rest/protocol.py +++ b/wsme/rest/protocol.py @@ -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)