Commit e4eed514 authored by Lukáš Lalinský's avatar Lukáš Lalinský

More forgiving URL parsing

parent 3a70dfca
......@@ -52,6 +52,16 @@ class JettyErrorPageParser(HTMLParser):
def parse_url(url):
url = urlparse.urlparse(url)
if not url.scheme and not url.netloc and url.path:
netloc = url.path
if ':' not in netloc:
netloc = '{}:8765'.format(netloc)
return urlparse.ParseResult('http', netloc, '/', '', '', '')
return url
class AvaticaClient(object):
"""Client for Avatica's RPC server.
......@@ -67,7 +77,7 @@ class AvaticaClient(object):
:param url:
URL of an Avatica RPC server.
self.url = urlparse.urlparse(url)
self.url = parse_url(url)
self.connection = None
def connect(self):
import unittest
import urlparse
from phoenixdb.avatica import parse_url
class ParseUrlTest(unittest.TestCase):
def test_parse_url(self):
self.assertEqual(urlparse.urlparse('http://localhost:8765/'), parse_url('localhost'))
self.assertEqual(urlparse.urlparse('http://localhost:2222/'), parse_url('localhost:2222'))
self.assertEqual(urlparse.urlparse('http://localhost:2222/'), parse_url('http://localhost:2222/'))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment