diff roundup/rest.py @ 5686:eb51c0d9c9bf

Move @apiver version extraction code after the input is parsed for json. Otherwise json input causes issues. test 400 return code if ;version=1.1. test for version param in accept header ;version=1 test version in type/vnd.subtype (vnd.json.test-v1) and @apiver=1 query param.
author John Rouillard <rouilj@ieee.org>
date Sun, 31 Mar 2019 21:46:23 -0400
parents 4b4885f0c6ad
children 83037aaf3b9d
line wrap: on
line diff
--- a/roundup/rest.py	Sun Mar 31 21:23:33 2019 -0400
+++ b/roundup/rest.py	Sun Mar 31 21:46:23 2019 -0400
@@ -1476,24 +1476,6 @@
                               part[1]['version']))
                     output = self.error_obj(400, msg)
 
-        # check for @apiver in query string
-        try:
-            if not self.api_version:
-                self.api_version = int(input['@apiver'].value)
-        except KeyError:
-            self.api_version = None
-        except ValueError:
-            msg=( "Unrecognized version: %s. "
-                  "See /rest without specifying version "
-                  "for supported versions."%(
-                      input['@apiver'].value))
-            output = self.error_obj(400, msg)
-
-        # FIXME: do we need to raise an error if client did not specify
-        # version? This may be a good thing to require. Note that:
-        # Accept: application/json; version=1 may not be legal but....
-        
-
         # get the request format for response
         # priority : extension from uri (/rest/data/issue.json),
         #            header (Accept: application/json, application/xml)
@@ -1550,6 +1532,23 @@
         except KeyError:
             pretty_output = True
 
+        # check for @apiver in query string
+        try:
+            if not self.api_version:
+                self.api_version = int(input['@apiver'].value)
+        except KeyError:
+            self.api_version = None
+        except ValueError:
+            msg=( "Unrecognized version: %s. "
+                  "See /rest without specifying version "
+                  "for supported versions."%(
+                      input['@apiver'].value))
+            output = self.error_obj(400, msg)
+
+        # FIXME: do we need to raise an error if client did not specify
+        # version? This may be a good thing to require. Note that:
+        # Accept: application/json; version=1 may not be legal but....
+        
         # Call the appropriate method
         try:
             # If output was defined by a prior error

Roundup Issue Tracker: http://roundup-tracker.org/