Skip to content

Commit

Permalink
Make port number optional in superset for druid (apache#5020)
Browse files Browse the repository at this point in the history
* Make port number optional in superset for druid

It appears that urllib throws error with ssl if port number is provided

```
    url = "https://example.com:443/druid/v2"

    req = urllib.request.Request(url, druid_query_str, headers)
    res = urllib.request.urlopen(req)

```

The above call fails with the following error:
```
urllib2.HTTPError: HTTP Error 404: Not Found
```

If url is set to https://example.com/druid/v2 it works, this change
makes the port number optional.

* Rewrite if/else in concisely python way

(cherry picked from commit 2bf53da)
  • Loading branch information
amalakar authored and hughhhh committed Jun 27, 2018
1 parent 54dc4de commit a03a4b1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion superset/connectors/druid/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ def data(self):
def get_base_url(host, port):
if not re.match('http(s)?://', host):
host = 'http://' + host
return '{0}:{1}'.format(host, port)

url = '{0}:{1}'.format(host, port) if port else host
return url

def get_base_coordinator_url(self):
base_url = self.get_base_url(
Expand Down

0 comments on commit a03a4b1

Please sign in to comment.