From 917aab06709687e1995e7b2fab0d6ba0aedf1f7d Mon Sep 17 00:00:00 2001 From: Dmitry Spikhalsky Date: Thu, 30 Oct 2025 21:02:19 -0400 Subject: [PATCH] Handle secondary TLS port 8443 as https by default --- tests/unit/test_dbapi.py | 1 + trino/constants.py | 1 + trino/dbapi.py | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_dbapi.py b/tests/unit/test_dbapi.py index 080a3904..b9b647e9 100644 --- a/tests/unit/test_dbapi.py +++ b/tests/unit/test_dbapi.py @@ -325,6 +325,7 @@ def test_description_is_none_when_cursor_is_not_executed(): ("http://mytrinoserver.domain:9999", None, None, constants.HTTP), # Infer from port ("mytrinoserver.domain", constants.DEFAULT_TLS_PORT, None, constants.HTTPS), + ("mytrinoserver.domain", constants.SECONDARY_TLS_PORT, None, constants.HTTPS), ("mytrinoserver.domain", constants.DEFAULT_PORT, None, constants.HTTP), # http_scheme parameter has higher precedence than port parameter ("mytrinoserver.domain", constants.DEFAULT_TLS_PORT, constants.HTTP, constants.HTTP), diff --git a/trino/constants.py b/trino/constants.py index b136aaaf..d84680a5 100644 --- a/trino/constants.py +++ b/trino/constants.py @@ -14,6 +14,7 @@ DEFAULT_PORT = 8080 DEFAULT_TLS_PORT = 443 +SECONDARY_TLS_PORT = 8443 DEFAULT_SOURCE = "trino-python-client" DEFAULT_CATALOG: Optional[str] = None DEFAULT_SCHEMA: Optional[str] = None diff --git a/trino/dbapi.py b/trino/dbapi.py index fb73cc38..d0adb4d2 100644 --- a/trino/dbapi.py +++ b/trino/dbapi.py @@ -208,7 +208,7 @@ def __init__( self.http_scheme = parsed_host.scheme elif http_scheme: self.http_scheme = http_scheme - elif port == constants.DEFAULT_TLS_PORT: + elif port in (constants.DEFAULT_TLS_PORT, constants.SECONDARY_TLS_PORT): self.http_scheme = constants.HTTPS elif port == constants.DEFAULT_PORT: self.http_scheme = constants.HTTP