From cc70e6d668789784e63f098091f51779b425a0c1 Mon Sep 17 00:00:00 2001
From: Marius van den Beek <m.vandenbeek@gmail.com>
Date: Sat, 16 Apr 2016 13:10:34 +0200
Subject: [PATCH] Include managers/<manager_name> in HttpPulsarInterface url.

If manager name was specified in the destination parameters, include the
managers/<manager_name> route in the url.
---
 pulsar/client/interface.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/pulsar/client/interface.py b/pulsar/client/interface.py
index 0882c91b..67cf44dc 100644
--- a/pulsar/client/interface.py
+++ b/pulsar/client/interface.py
@@ -3,14 +3,12 @@ from abc import abstractmethod
 from string import Template
 
 from six import BytesIO
+from six.moves.urllib.parse import urlencode
+from six.moves.urllib.parse import urljoin
 try:
     from six import text_type
 except ImportError:
     from galaxy.util import unicodify as text_type
-try:
-    from urllib import urlencode
-except ImportError:
-    from urllib.parse import urlencode
 
 from .util import copy_to_path
 
@@ -85,10 +83,13 @@ class HttpPulsarInterface(PulsarInterface):
         self.transport = transport
         remote_host = destination_params.get("url")
         assert remote_host is not None, "Failed to determine url for Pulsar client."
-        if not remote_host.endswith("/"):
-            remote_host = "%s/" % remote_host
         if not remote_host.startswith("http"):
             remote_host = "http://%s" % remote_host
+        if not remote_host.endswith("/"):
+            remote_host = "%s/" % remote_host
+        manager = destination_params.get("manager", None)
+        if manager:
+            remote_host = urljoin(remote_host, "managers/%s" % manager)
         self.remote_host = remote_host
         self.private_token = destination_params.get("private_token", None)
 
-- 
GitLab