Skip to content

Commit 3390d45

Browse files
committed
Add support for protocol-relative request paths
Nuclos generates protocol-relative HATEOEAS links since version 4.32. Note that we currently only support the HTTP protocol, so that gets added to any protocol-relative path.
1 parent 9961864 commit 3390d45

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ A Python library for the REST API of [Nuclos](http://www.nuclos.de/).
66

77
| Version | Compatible Nuclos versions | Download |
88
| --------------------------------------------------------------- | -------------------------- | -------- |
9-
| [1.7](https://github.com/saierd/python-nuclos/releases/tag/1.7) | ≥ 4.7.2<br>(tested up to 4.30 as of writing)| [zip](https://github.com/saierd/python-nuclos/releases/download/1.7/python-nuclos-1.7.zip) |
9+
| [1.8](https://github.com/saierd/python-nuclos/releases/tag/1.8) | ≥ 4.7.2<br>(tested up to 4.44 as of writing)| [zip](https://github.com/saierd/python-nuclos/releases/download/1.8/python-nuclos-1.8.zip) |
10+
| [1.7](https://github.com/saierd/python-nuclos/releases/tag/1.7) | 4.7.2 - 4.31 | [zip](https://github.com/saierd/python-nuclos/releases/download/1.7/python-nuclos-1.7.zip) |
1011
| [1.4](https://github.com/saierd/python-nuclos/releases/tag/1.4) | 4.5.* | [zip](https://github.com/saierd/python-nuclos/releases/download/1.4/python-nuclos-1.4.zip) |
1112
| [1.0](https://github.com/saierd/python-nuclos/releases/tag/1.0) | 4.4.0 | [zip](https://github.com/saierd/python-nuclos/releases/download/1.0/python-nuclos-1.0.zip) |
1213

nuclos.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
STATE_CHANGE_ROUTE = "boStateChanges/{}/{}/{}"
3838
DOCUMENT_ROUTE = "boDocuments/{}/{}/documents/{}"
3939

40+
HTTP_PROTOCOL = "http"
41+
4042

4143
class NuclosSettings:
4244
def __init__(self, filename):
@@ -334,7 +336,9 @@ def request(self, path, parameters=None, data=None, method=None, auto_login=True
334336
self.login()
335337

336338
url = path
337-
if not url.startswith("http"):
339+
if url.startswith("//"):
340+
url = HTTP_PROTOCOL + ":" + url
341+
if not url.startswith(HTTP_PROTOCOL):
338342
url = self._build_url(path, parameters)
339343
request = urllib.request.Request(url)
340344
if json_answer:
@@ -408,7 +412,7 @@ def quote(s):
408412
if not path.startswith("/"):
409413
path = "/" + path
410414

411-
url = "http://{}:{}/{}/rest{}".format(quote(self.settings.ip), self.settings.port,
415+
url = "{}://{}:{}/{}/rest{}".format(HTTP_PROTOCOL, quote(self.settings.ip), self.settings.port,
412416
quote(self.settings.instance), quote(path))
413417
if param:
414418
url += "?" + param

0 commit comments

Comments
 (0)