From 19e91633673261737494a4138af9d90edc0d329b Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 26 Aug 2015 13:39:46 +0200 Subject: [PATCH] [FIX] google_drive: code want uncompressed data This commit removes the request of having gzip or deflate data for two requests to google drive API. Previously the code worked since google api would send ungzipped data (maybe base on urllib2 user agent or other input parameters) but after a recent change on google part, it is not anymore the case. closes #8243 opw-648007 note: if we did not do this, we would either need to use requests or add custom uncompressing code for urllib2 response content. --- addons/google_drive/google_drive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/google_drive/google_drive.py b/addons/google_drive/google_drive.py index 8af18639299..3976d561c40 100644 --- a/addons/google_drive/google_drive.py +++ b/addons/google_drive/google_drive.py @@ -80,7 +80,7 @@ class config(osv.Model): client_secret=google_drive_client_secret, grant_type="refresh_token", scope=scope or 'https://www.googleapis.com/auth/drive')) - headers = {"Content-type": "application/x-www-form-urlencoded", "Accept-Encoding": "gzip, deflate"} + headers = {"Content-type": "application/x-www-form-urlencoded"} try: req = urllib2.Request('https://accounts.google.com/o/oauth2/token', data, headers) content = urllib2.urlopen(req, timeout=TIMEOUT).read() @@ -100,7 +100,7 @@ class config(osv.Model): access_token = self.get_access_token(cr, uid, context=context) # Copy template in to drive with help of new access token request_url = "https://www.googleapis.com/drive/v2/files/%s?fields=parents/id&access_token=%s" % (template_id, access_token) - headers = {"Content-type": "application/x-www-form-urlencoded", "Accept-Encoding": "gzip, deflate"} + headers = {"Content-type": "application/x-www-form-urlencoded"} try: req = urllib2.Request(request_url, None, headers) parents = urllib2.urlopen(req, timeout=TIMEOUT).read()