From 36eb6db80b526ac026f975b8dfc0e3b052bb7e06 Mon Sep 17 00:00:00 2001 From: gdliu3 Date: Thu, 25 Jul 2024 20:34:13 +0800 Subject: [PATCH 1/3] 1 --- .../apache/seatunnel/connectors/doris/util/HttpUtil.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/util/HttpUtil.java b/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/util/HttpUtil.java index 46d1126c2fe..3c085add603 100644 --- a/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/util/HttpUtil.java +++ b/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/util/HttpUtil.java @@ -17,15 +17,23 @@ package org.apache.seatunnel.connectors.doris.util; +import org.apache.http.HttpRequestInterceptor; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.DefaultRedirectStrategy; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClients; +import org.apache.http.protocol.HTTP; /** util to build http client. */ public class HttpUtil { private final HttpClientBuilder httpClientBuilder = HttpClients.custom() + .addInterceptorFirst( + (HttpRequestInterceptor) + (request, context) -> { + //If there is no data for the first time, TRANSFER_ENCODING will be added to the request header. Doris initiates a redirect to be and checks whether there is TRANSFER_ENCODING in the request header. If there is, it will be abnormal, so it needs to be removed. + request.removeHeaders(HTTP.TRANSFER_ENCODING); + }) .setRedirectStrategy( new DefaultRedirectStrategy() { @Override From 6391d515fe63cb1997681356c38e1c4312933e26 Mon Sep 17 00:00:00 2001 From: Jia Fan Date: Fri, 26 Jul 2024 08:56:56 +0800 Subject: [PATCH 2/3] format --- .../seatunnel/connectors/doris/util/HttpUtil.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/util/HttpUtil.java b/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/util/HttpUtil.java index 3c085add603..28296c66d38 100644 --- a/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/util/HttpUtil.java +++ b/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/util/HttpUtil.java @@ -29,11 +29,15 @@ public class HttpUtil { private final HttpClientBuilder httpClientBuilder = HttpClients.custom() .addInterceptorFirst( - (HttpRequestInterceptor) - (request, context) -> { - //If there is no data for the first time, TRANSFER_ENCODING will be added to the request header. Doris initiates a redirect to be and checks whether there is TRANSFER_ENCODING in the request header. If there is, it will be abnormal, so it needs to be removed. - request.removeHeaders(HTTP.TRANSFER_ENCODING); - }) + (HttpRequestInterceptor) + (request, context) -> { + // If there is no data for the first time, TRANSFER_ENCODING + // will be added to the request header. Doris initiates a + // redirect to be and checks whether there is + // TRANSFER_ENCODING in the request header. If there is, it + // will be abnormal, so it needs to be removed. + request.removeHeaders(HTTP.TRANSFER_ENCODING); + }) .setRedirectStrategy( new DefaultRedirectStrategy() { @Override From 026341a371f5712238fb6fe30eb9e70a9c775313 Mon Sep 17 00:00:00 2001 From: gdliu3 Date: Fri, 26 Jul 2024 09:48:16 +0800 Subject: [PATCH 3/3] 1 --- .../connectors/doris/util/HttpUtil.java | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/util/HttpUtil.java b/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/util/HttpUtil.java index 28296c66d38..aa70d1f290a 100644 --- a/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/util/HttpUtil.java +++ b/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/util/HttpUtil.java @@ -17,34 +17,24 @@ package org.apache.seatunnel.connectors.doris.util; -import org.apache.http.HttpRequestInterceptor; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.DefaultRedirectStrategy; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClients; -import org.apache.http.protocol.HTTP; +import org.apache.http.protocol.RequestContent; /** util to build http client. */ public class HttpUtil { private final HttpClientBuilder httpClientBuilder = HttpClients.custom() - .addInterceptorFirst( - (HttpRequestInterceptor) - (request, context) -> { - // If there is no data for the first time, TRANSFER_ENCODING - // will be added to the request header. Doris initiates a - // redirect to be and checks whether there is - // TRANSFER_ENCODING in the request header. If there is, it - // will be abnormal, so it needs to be removed. - request.removeHeaders(HTTP.TRANSFER_ENCODING); - }) .setRedirectStrategy( new DefaultRedirectStrategy() { @Override protected boolean isRedirectable(String method) { return true; } - }); + }) + .addInterceptorLast(new RequestContent(true));; public CloseableHttpClient getHttpClient() { return httpClientBuilder.build();