Skip to content

Commit 3d37343

Browse files
committed
ResponseBody: New media-types application/xml, text/xml
We use xml.dom.minidom to de-serialize the results.
1 parent 6a44c59 commit 3d37343

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

agithub.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import re
66
from functools import partial, update_wrapper
77

8+
import xml.dom.minidom
9+
810
import sys
911
if sys.version_info[0:2] > (3,0):
1012
import http.client
@@ -388,6 +390,22 @@ def application_json(self):
388390
# XXX: This isn't technically correct, but we'll hope for the best.
389391
# Patches welcome!
390392

393+
def application_xml(self):
394+
self.decodeBody()
395+
396+
try:
397+
pybody = xml.dom.minidom.parseString(self.body)
398+
except Exception: #TODO: What kind of exceptions?
399+
pybody = self.body
400+
401+
return pybody
402+
403+
404+
text_xml = application_xml
405+
# The difference between text/xml and application/xml is whether it
406+
# is human-readable or not. For our purposes, there is no
407+
# difference. RFC 3023, L270.
408+
391409
# Insert new Response media-type handlers here
392410

393411
class RequestBody(Body):

0 commit comments

Comments
 (0)