Skip to content

Commit d3c4010

Browse files
author
kamillecao
committed
add setting to force use post.
1 parent 2b54e48 commit d3c4010

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub struct Client {
4444
database: Option<String>,
4545
authentication: Authentication,
4646
compression: Compression,
47+
force_use_post: bool,
4748
options: HashMap<String, String>,
4849
headers: HashMap<String, String>,
4950
products_info: Vec<ProductInfo>,
@@ -98,6 +99,7 @@ impl Client {
9899
database: None,
99100
authentication: Authentication::default(),
100101
compression: Compression::default(),
102+
force_use_post: false,
101103
options: HashMap::new(),
102104
headers: HashMap::new(),
103105
products_info: Vec::default(),
@@ -232,6 +234,18 @@ impl Client {
232234
self
233235
}
234236

237+
/// Used to specify if we use post to send request explicitly
238+
///
239+
/// # Example
240+
/// ```
241+
/// # use clickhouse::Client;
242+
/// Client::default().with_force_to_use_post(true);
243+
/// ```
244+
pub fn with_force_to_use_post(mut self, force_to_use_post: bool) -> Self {
245+
self.force_use_post = force_to_use_post;
246+
self
247+
}
248+
235249
/// Used to specify a header that will be passed to all queries.
236250
///
237251
/// # Example

src/query.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ impl Query {
155155
pairs.append_pair("database", database);
156156
}
157157

158-
let use_post = !read_only || query.len() > MAX_QUERY_LEN_TO_USE_GET;
158+
let use_post =
159+
!read_only || query.len() > MAX_QUERY_LEN_TO_USE_GET || self.client.force_use_post;
159160

160161
let (method, body, content_length) = if use_post {
161162
if read_only {

0 commit comments

Comments
 (0)