Skip to content

Commit 2a31cc9

Browse files
authored
Merge branch 'dev' into ast-parsing
2 parents dc9b395 + f1b56f7 commit 2a31cc9

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

appdaemon/http.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ async def wrapper(*args):
9696
return await myfunc(*args)
9797

9898
elif "adcreds" in request.cookies:
99-
match = await utils.run_in_executor(
100-
self, bcrypt.checkpw, str.encode(self.password), str.encode(request.cookies["adcreds"])
101-
)
99+
match = await utils.run_in_executor(self, bcrypt.checkpw, str.encode(self.password), str.encode(request.cookies["adcreds"]))
102100
if match:
103101
return await myfunc(*args)
104102

@@ -176,12 +174,19 @@ def __init__(self, ad: "AppDaemon", dashboard, old_admin, admin, api, http):
176174

177175
try:
178176
url = urlparse(self.url)
179-
180177
self.host = url.hostname
181-
try:
178+
self.scheme = url.scheme
179+
180+
if url.port is None:
181+
match url.scheme:
182+
case "http":
183+
self.port = 80
184+
case "https":
185+
self.port = 443
186+
case _:
187+
self.port = None # let the validation catch it
188+
else:
182189
self.port = url.port
183-
except IndexError:
184-
self.port = 80
185190

186191
if self.host == "":
187192
raise ValueError("Invalid host for 'url'")
@@ -373,9 +378,7 @@ def _process_http(self, http):
373378

374379
self._process_arg("url", http)
375380
if not self.url:
376-
self.logger.warning(
377-
"'{arg}' is '{value}'. Please configure appdaemon.yaml".format(arg="url", value=self.url)
378-
)
381+
self.logger.warning("'{arg}' is '{value}'. Please configure appdaemon.yaml".format(arg="url", value=self.url))
379382
exit(0)
380383

381384
self._process_arg("transport", http)

docs/HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ None
1616
- Fixed a bug where changing files at exactly right time would throw an error
1717
- Files with syntax errors get added to `bad_files` list, even if they aren't used for apps
1818
- Improved error text for `ImportErrors` and `SyntaxErrors` in user apps
19+
- Add a fix to the http component to handle URLs with no port, and URLs with port 80
1920

2021
**Breaking Changes**
2122

0 commit comments

Comments
 (0)