mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-09 17:14:47 +00:00
Add raw content option to http helper methods
This commit is contained in:
parent
fb90c57918
commit
33037334a5
@ -3385,6 +3385,7 @@ class ClickHouseInstance:
|
||||
port=8123,
|
||||
timeout=None,
|
||||
retry_strategy=None,
|
||||
content=False,
|
||||
):
|
||||
output, error = self.http_query_and_get_answer_with_error(
|
||||
sql,
|
||||
@ -3396,6 +3397,7 @@ class ClickHouseInstance:
|
||||
port=port,
|
||||
timeout=timeout,
|
||||
retry_strategy=retry_strategy,
|
||||
content=content,
|
||||
)
|
||||
|
||||
if error:
|
||||
@ -3448,6 +3450,7 @@ class ClickHouseInstance:
|
||||
port=8123,
|
||||
timeout=None,
|
||||
retry_strategy=None,
|
||||
content=False,
|
||||
):
|
||||
logging.debug(f"Executing query {sql} on {self.name} via HTTP interface")
|
||||
if params is None:
|
||||
@ -3479,7 +3482,7 @@ class ClickHouseInstance:
|
||||
r = requester.request(method, url, data=data, auth=auth, timeout=timeout)
|
||||
|
||||
if r.ok:
|
||||
return (r.text, None)
|
||||
return (r.content if content else r.text, None)
|
||||
|
||||
code = r.status_code
|
||||
return (None, str(code) + " " + http.client.responses[code] + ": " + r.text)
|
||||
|
@ -18,10 +18,12 @@ def setup_nodes():
|
||||
def test_http_native_returns_timezone():
|
||||
# No timezone when no protocol version sent
|
||||
query = "SELECT toDateTime(1676369730, 'Asia/Shanghai') as dt FORMAT Native"
|
||||
raw = instance.http_query(query)
|
||||
raw = instance.http_query(query, content=True)
|
||||
assert raw.hex(" ", 2) == "0101 0264 7408 4461 7465 5469 6d65 425f eb63"
|
||||
|
||||
# Timezone available when protocol version sent
|
||||
raw = instance.http_query(query, params={"client_protocol_version": 54337})
|
||||
raw = instance.http_query(
|
||||
query, params={"client_protocol_version": 54337}, content=True
|
||||
)
|
||||
ch_type = raw[14:39].decode()
|
||||
assert ch_type == "DateTime('Asia/Shanghai')"
|
||||
|
Loading…
Reference in New Issue
Block a user