Chromium Code Reviews| Index: remoting/client/appengine/api.py |
| diff --git a/remoting/client/appengine/api.py b/remoting/client/appengine/api.py |
| index ec16fc63cd7f468e4506f78d0de956242ddb983d..babb923a799a1593280ac936dbdcd7617d024bf5 100644 |
| --- a/remoting/client/appengine/api.py |
| +++ b/remoting/client/appengine/api.py |
| @@ -10,8 +10,7 @@ import logging |
| from django.utils import simplejson as json |
| -import gdata.client |
| - |
| +from google.appengine.api import urlfetch |
| from google.appengine.ext import webapp |
| from google.appengine.ext.webapp import util |
| from google.appengine.ext.webapp.util import login_required |
| @@ -30,26 +29,21 @@ class GetXmppTokenHandler(webapp.RequestHandler): |
| self.response.out.write('User has not authenticated') |
| self.set_status(400) |
| + |
| class GetHostListHandler(webapp.RequestHandler): |
| """Proxies the host-list handlers on the Chromoting directory.""" |
| @login_required |
| def get(self): |
| - try: |
| - client = gdata.client.GDClient() |
| - host_list_json = client.Request( |
| - method='GET', |
| - uri="https://www.googleapis.com/chromoting/v1/@me/hosts", |
| - converter=None, |
| - desired_class=None, |
| - auth_token=auth.GetChromotingToken()) |
| - self.response.headers['Content-Type'] = 'application/json' |
| - self.response.out.write(host_list_json.read()) |
| - except auth.NotAuthenticated: |
| - self.response.out.write('User has not authenticated') |
| - self.response.set_status(400) |
| - except (gdata.client.Unauthorized, gdata.client.RequestError), inst: |
| - self.response.out.write(inst.reason) |
| - self.response.set_status(inst.status) |
| + result = urlfetch.fetch( |
| + url = 'https://www.googleapis.com/chromoting/v1/@me/hosts', |
| + method = urlfetch.GET, |
| + headers = {'Authorization': 'OAuth ' + auth.GetAccessToken()}) |
| + self.response.headers['Content-Type'] = 'application/json' |
|
Jamie
2011/05/20 16:46:47
In the previous code, the content-type was only se
awong
2011/05/20 20:37:38
Good catch. Actually, I'm just relaying the full
|
| + self.response.out.write(result.content) |
|
Jamie
2011/05/20 16:46:47
Does |write| write the data to the client immediat
awong
2011/05/20 20:37:38
I'm pretty sure it's not a streaming response. Bu
|
| + for i in result.headers: |
| + self.response.headers[i] = result.headers[i] |
| + self.response.set_status(result.status_code) |
| + |
| def main(): |
| application = webapp.WSGIApplication( |