|
14 | 14 | import com.clickhouse.client.api.enums.ProxyType;
|
15 | 15 | import com.clickhouse.client.api.http.ClickHouseHttpProto;
|
16 | 16 | import com.clickhouse.client.api.transport.Endpoint;
|
| 17 | +import com.clickhouse.data.ClickHouseFormat; |
17 | 18 | import net.jpountz.lz4.LZ4Factory;
|
18 | 19 | import org.apache.hc.client5.http.ConnectTimeoutException;
|
19 | 20 | import org.apache.hc.client5.http.classic.methods.HttpPost;
|
@@ -450,13 +451,13 @@ private void addHeaders(HttpPost req, Map<String, Object> requestConfig) {
|
450 | 451 | addHeader(
|
451 | 452 | req,
|
452 | 453 | ClickHouseHttpProto.HEADER_FORMAT,
|
453 |
| - requestConfig.get(ClientConfigProperties.INPUT_OUTPUT_FORMAT.getKey())); |
| 454 | + ((ClickHouseFormat) requestConfig.get(ClientConfigProperties.INPUT_OUTPUT_FORMAT.getKey())).name()); |
454 | 455 | }
|
455 | 456 | if (requestConfig.containsKey(ClientConfigProperties.QUERY_ID.getKey())) {
|
456 | 457 | addHeader(
|
457 | 458 | req,
|
458 | 459 | ClickHouseHttpProto.HEADER_QUERY_ID,
|
459 |
| - requestConfig.get(ClientConfigProperties.QUERY_ID.getKey())); |
| 460 | + (String) requestConfig.get(ClientConfigProperties.QUERY_ID.getKey())); |
460 | 461 | }
|
461 | 462 | addHeader(
|
462 | 463 | req,
|
@@ -758,22 +759,22 @@ public void close() {
|
758 | 759 | }
|
759 | 760 |
|
760 | 761 | private static <T> void addHeader(HttpRequest req, String headerName,
|
761 |
| - T value) |
| 762 | + String value) |
762 | 763 | {
|
763 | 764 | if (value == null) {
|
764 | 765 | return;
|
765 | 766 | }
|
766 |
| - String tString = value.toString(); |
767 |
| - if (tString == null || tString.trim().isEmpty()) { |
| 767 | + |
| 768 | + if (value.trim().isEmpty()) { |
768 | 769 | return;
|
769 | 770 | }
|
770 |
| - if (PATTERN_HEADER_VALUE_ASCII.matcher(tString).matches()) { |
771 |
| - req.addHeader(headerName, tString); |
| 771 | + if (PATTERN_HEADER_VALUE_ASCII.matcher(value).matches()) { |
| 772 | + req.addHeader(headerName, value); |
772 | 773 | } else {
|
773 | 774 | try {
|
774 | 775 | req.addHeader(
|
775 | 776 | headerName + "*",
|
776 |
| - "UTF-8''" + URLEncoder.encode(tString, StandardCharsets.UTF_8.name())); |
| 777 | + "UTF-8''" + URLEncoder.encode(value, StandardCharsets.UTF_8.name())); |
777 | 778 | } catch (UnsupportedEncodingException e) {
|
778 | 779 | throw new ClientException("Failed to convert string to UTF8" , e);
|
779 | 780 | }
|
|
0 commit comments