Juan Hernandez has uploaded a new change for review.

Change subject: sdk: Remove trailing slashes from URL prefix
......................................................................

sdk: Remove trailing slashes from URL prefix

Currently we get the URL prefix of the RESTAPI from the URL provided by
the user, without modification. If this prefix contains trailing slashes we
end up building complete URLs that contain two slashes. For example, if
the user writes this code:

  api = ovirtsdk.api.API(url='https://whatever/api/', ...)
  api.clusters.list()

We send the following request to the server:

  GET /api//clusters HTTP/1.1

The server doesn't accept these two slashes and generates an error
response.

To fix this issue this patch removes trailing slashes from the URL
prefix.

Change-Id: I7a75aeccd7ba42fa3d49c4cebb9fc0ab3eff5cb9
Bug-Url: https://bugzilla.redhat.com/1063746
Signed-off-by: Juan Hernandez <juan.hernan...@redhat.com>
(cherry picked from commit 61ac75bc23f8aa9346ab774ee272894fb8259595)
---
M src/codegen/templates/entrypointtemplate
M src/ovirtsdk/api.py
2 files changed, 4 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-sdk refs/changes/18/24318/1

diff --git a/src/codegen/templates/entrypointtemplate 
b/src/codegen/templates/entrypointtemplate
index 1132ef1..661a412 100644
--- a/src/codegen/templates/entrypointtemplate
+++ b/src/codegen/templates/entrypointtemplate
@@ -57,8 +57,8 @@
         )
 
         # Extract from the entry point URL the prefix common to paths
-        # of all requests:
-        prefix = urlparse.urlparse(url).path
+        # of all requests and remove trailing slashes:
+        prefix = urlparse.urlparse(url).path.rstrip('/')
 
         # Create the proxy:
         proxy = Proxy(
diff --git a/src/ovirtsdk/api.py b/src/ovirtsdk/api.py
index 9daa28c..a7fa987 100644
--- a/src/ovirtsdk/api.py
+++ b/src/ovirtsdk/api.py
@@ -113,8 +113,8 @@
         )
 
         # Extract from the entry point URL the prefix common to paths
-        # of all requests:
-        prefix = urlparse.urlparse(url).path
+        # of all requests and remove trailing slashes:
+        prefix = urlparse.urlparse(url).path.rstrip('/')
 
         # Create the proxy:
         proxy = Proxy(


-- 
To view, visit http://gerrit.ovirt.org/24318
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7a75aeccd7ba42fa3d49c4cebb9fc0ab3eff5cb9
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine-sdk
Gerrit-Branch: sdk_3.3
Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to