Commits

Alexander Herrmann committed cf01909

fixed handling of empty request body in xml emitter

Comments (0)

Files changed (1)

piston/emitters.py

     
     @staticmethod
     def parse_xml(xml):
-        dict = xml2dict.fromstring(xml)
-        # there is only one first node
-        return dict[dict.keys()[0]]
+        if len(xml) > 0:
+            dict = xml2dict.fromstring(xml)
+            # there is only one first node
+            return dict[dict.keys()[0]]
+        return {}
 
 Emitter.register('xml', XMLEmitter, 'text/xml; charset=utf-8')
 if xml2dict: # if import was successfull