From notifications-return-14183-archive-asf-public=cust-asf.ponee.io@libcloud.apache.org Mon Jan 8 13:32:35 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id B1FAB180607 for ; Mon, 8 Jan 2018 13:32:35 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id A1BF9160C2C; Mon, 8 Jan 2018 12:32:35 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E7D80160C1E for ; Mon, 8 Jan 2018 13:32:34 +0100 (CET) Received: (qmail 21105 invoked by uid 500); 8 Jan 2018 12:32:34 -0000 Mailing-List: contact notifications-help@libcloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@libcloud.apache.org Delivered-To: mailing list notifications@libcloud.apache.org Received: (qmail 21096 invoked by uid 500); 8 Jan 2018 12:32:34 -0000 Delivered-To: apmail-libcloud-commits@libcloud.apache.org Received: (qmail 21093 invoked by uid 99); 8 Jan 2018 12:32:34 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Jan 2018 12:32:34 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id EB6ACDFCB5; Mon, 8 Jan 2018 12:32:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: quentinp@apache.org To: commits@libcloud.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: libcloud git commit: Fix improper getresponse() uses Date: Mon, 8 Jan 2018 12:32:30 +0000 (UTC) Repository: libcloud Updated Branches: refs/heads/trunk 27ca9167c -> 23f400ed6 Fix improper getresponse() uses Closes #1133 During the migration from httplib to requests, a lot of driver code did not change because they use the high-level libcloud API which hid the change from httplib to requests with the HttpLibResponseProxy adapter. However, in some cases, driver code needs to access the actual response, and does this by calling getresponse(). While this used to return an httlib.HTTPResponse instance, this now returns a requests.Response instance. All code covered by tests was fixed, but OVH and Brightbox common code is not fully covered. I don't have a subscription to either service and can't test the change, but the resulting code can only be more correct since it fixes the `getresponse() result comes from httplib` assumption. Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/23f400ed Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/23f400ed Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/23f400ed Branch: refs/heads/trunk Commit: 23f400ed6d7902284ba316730c7550c0c76937e1 Parents: 27ca916 Author: Quentin Pradet Authored: Mon Oct 16 14:11:50 2017 +0400 Committer: Quentin Pradet Committed: Mon Jan 8 16:32:03 2018 +0400 ---------------------------------------------------------------------- libcloud/common/brightbox.py | 5 ++--- libcloud/common/ovh.py | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/23f400ed/libcloud/common/brightbox.py ---------------------------------------------------------------------- diff --git a/libcloud/common/brightbox.py b/libcloud/common/brightbox.py index 1943dda..77270c0 100644 --- a/libcloud/common/brightbox.py +++ b/libcloud/common/brightbox.py @@ -78,12 +78,11 @@ class BrightboxConnection(ConnectionUserAndKey): response = self.connection.request(method='POST', url='/token', body=body, headers=headers) - response = self.connection.getresponse() - if response.status == httplib.OK: return json.loads(response.read())['access_token'] else: - responseCls = BrightboxResponse(response=response, connection=self) + responseCls = BrightboxResponse( + response=response.getresponse(), connection=self) message = responseCls.parse_error() raise InvalidCredsError(message) http://git-wip-us.apache.org/repos/asf/libcloud/blob/23f400ed/libcloud/common/ovh.py ---------------------------------------------------------------------- diff --git a/libcloud/common/ovh.py b/libcloud/common/ovh.py index 260ea41..733ab07 100644 --- a/libcloud/common/ovh.py +++ b/libcloud/common/ovh.py @@ -104,13 +104,12 @@ class OvhConnection(ConnectionUserAndKey): } httpcon = LibcloudConnection(host=self.host, port=443) httpcon.request(method='POST', url=action, body=data, headers=headers) - response = httpcon.getresponse() + response = JsonResponse(httpcon.getresponse(), httpcon) if response.status == httplib.UNAUTHORIZED: raise InvalidCredsError() - body = response.read() - json_response = json.loads(body) + json_response = response.parse_body() httpcon.close() return json_response