summaryrefslogtreecommitdiffstats
path: root/echo
diff options
context:
space:
mode:
authorbsirish <sirish.bitra@gmail.com>2011-04-18 19:26:30 +0530
committerbsirish <sirish.bitra@gmail.com>2011-04-18 19:26:30 +0530
commit38318ba95f4e71ce23e8907cd3f762e0d5fd0867 (patch)
treea4e07db67276450785169ae4fa6bfef37395d155 /echo
parent2c5a4508ef10d16ab353cec5087b04979deabc78 (diff)
downloadkeystone-38318ba95f4e71ce23e8907cd3f762e0d5fd0867.tar.gz
keystone-38318ba95f4e71ce23e8907cd3f762e0d5fd0867.tar.xz
keystone-38318ba95f4e71ce23e8907cd3f762e0d5fd0867.zip
Code by Dev Team
Diffstat (limited to 'echo')
-rw-r--r--echo/echo.py40
1 files changed, 22 insertions, 18 deletions
diff --git a/echo/echo.py b/echo/echo.py
index e59deab7..5cb4b2b7 100644
--- a/echo/echo.py
+++ b/echo/echo.py
@@ -21,7 +21,9 @@ try:
except ImportError:
import json
import eventlet
-import urllib2
+import urllib
+from httplib2 import Http
+
class EchoApp:
@@ -42,17 +44,23 @@ class EchoApp:
def toJSON(self):
-
+ self.start('200 OK', [('Content-Type', 'application/json')])
token = str(self.envr.get("HTTP_X_AUTH_TOKEN",""))
if token !='':
- response=self.ValidateToken({'type':'json','token':token})
- r=json.loads('{"auth" : { "token": {"id": "fad94013a5b3b836dbc18", "expires": "2011-04-18 16:17:59"}}}')
-
+ res=self.ValidateToken({'type':'json','token':token})
+
+ if int(res['response']['status'])==200 :
+
+ yield str(res['content'])
+ else:
+ pass
+ # Need to Do Something Here
+ else:
+
+ yield str(self.transform(self.dom))
- self.start('200 OK', [('Content-Type', 'application/json')])
- yield str(self.transform(self.dom))
@@ -80,18 +88,14 @@ class EchoApp:
if params['token']:
- url = "http://localhost:8080/token/"+str(params['token'])
- #print url
- data = '{"test":""}'
- if params['type']=='json':
- headers = { "Accept" : "application/json", "Content-Type": "application/json",'REQUEST_METHOD':'GET' }
- elif type =='xml':
- headers = { "Accept" : "application/xml", "Content-Type": "application/xml" }
-
- req = urllib2.Request(url, data, headers)
- response = urllib2.urlopen(req)
+
+ http=Http()
- return response.read()
+ url = "http://localhost:8080/token/"+str(params['token'])
+ body = {}
+ headers = {"Accept" : "application/json", "Content-Type": "application/json"}
+ response, content = http.request(url, 'GET', headers=headers, body=urllib.urlencode(body))
+ return {'response':response,'content':content}
else:
return abort(401, "No Token Found!")