File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212DEFAULT_READ_TIMEOUT_SECONDS : float = 0.25
1313DEFAULT_SESSION_WAIT_TIMEOUT_SECONDS : float = 300
1414MAX_MESSAGE_SIZE : int = 100 * 2 ** 20 # 100MiB
15+ PROTOCOL_VERSION : str = "1.0.0"
1516
1617
1718class ExecutionState (LowercaseStrEnum ):
Original file line number Diff line number Diff line change 44"""
55
66import logging
7+ import os
78import urllib .parse
89import queue
910import requests
1819 DEFAULT_READ_TIMEOUT_SECONDS ,
1920 DEFAULT_SESSION_WAIT_TIMEOUT_SECONDS ,
2021 MAX_MESSAGE_SIZE ,
22+ PROTOCOL_VERSION ,
2123 ResultsFormat ,
2224 DataCompression ,
2325 GeometryRepresentation ,
@@ -134,6 +136,11 @@ def http_to_ws(uri: str) -> str:
134136 return str (urllib .parse .urlunparse (parsed ))
135137
136138
139+ def append_protocol (uri : str , protocol : str ) -> str :
140+ """Appends the protocol version to the URI."""
141+ return urllib .parse .urljoin (os .path .join (uri , "" ), protocol )
142+
143+
137144def connect_direct (
138145 uri : str ,
139146 headers : dict [str , str ] = None ,
@@ -143,12 +150,13 @@ def connect_direct(
143150 geometry_representation : GeometryRepresentation | None = None ,
144151) -> Connection :
145152 q = queue .SimpleQueue ()
153+ uri_with_protocol = append_protocol (uri , PROTOCOL_VERSION )
146154
147155 def create_ws_connection ():
148156 try :
149- logging .info ("Connecting to SQL session at %s ..." , uri )
157+ logging .info ("Connecting to SQL session at %s ..." , uri_with_protocol )
150158 ws = websockets .sync .client .connect (
151- uri = uri ,
159+ uri = uri_with_protocol ,
152160 additional_headers = headers ,
153161 max_size = MAX_MESSAGE_SIZE ,
154162 )
You can’t perform that action at this time.
0 commit comments