summaryrefslogtreecommitdiffstats
path: root/echo
diff options
context:
space:
mode:
authorJorge L. Williams <jorge.williams@rackspace.com>2011-04-15 07:09:42 -0500
committerJorge L. Williams <jorge.williams@rackspace.com>2011-04-15 07:09:42 -0500
commit52fff33e4b0c3164a07842ddb58e8dd0733aec48 (patch)
treefb27f0d31002c0749832868702c82c9876342ab2 /echo
parent577bab5c6698f7c37dc2930c2576297260d7059e (diff)
Added content nagotiation.
Diffstat (limited to 'echo')
-rw-r--r--echo/echo.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/echo/echo.py b/echo/echo.py
index 742521e8..85db57c8 100644
--- a/echo/echo.py
+++ b/echo/echo.py
@@ -20,12 +20,16 @@ import eventlet
class EchoApp:
def __init__(self, environ, start_response):
+ self.envr = environ
self.start = start_response
self.dom = self.toDOM(environ)
self.transform = etree.XSLT(etree.parse("xsl/echo.xsl"))
def __iter__(self):
- return self.toJSON()
+ if self.envr["HTTP_ACCEPT"] == "application/xml":
+ return self.toXML()
+ else:
+ return self.toJSON()
def toJSON(self):
self.start('200 OK', [('Content-Type', 'application/json')])