Skip to content

Commit c86ece5

Browse files
Hisoka-XThomas-HuWei
authored andcommitted
[Fix][Connector-V2] Fix starrocks Content-Length header already present error (apache#7034)
1 parent 83f1097 commit c86ece5

File tree

1 file changed

+10
-0
lines changed
  • seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/client

1 file changed

+10
-0
lines changed

seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/client/HttpHelper.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.apache.seatunnel.connectors.seatunnel.starrocks.config.SinkConfig;
2222

2323
import org.apache.http.HttpEntity;
24+
import org.apache.http.HttpRequestInterceptor;
2425
import org.apache.http.HttpStatus;
2526
import org.apache.http.client.config.RequestConfig;
2627
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -32,6 +33,7 @@
3233
import org.apache.http.impl.client.DefaultRedirectStrategy;
3334
import org.apache.http.impl.client.HttpClientBuilder;
3435
import org.apache.http.impl.client.HttpClients;
36+
import org.apache.http.protocol.HTTP;
3537
import org.apache.http.util.EntityUtils;
3638

3739
import lombok.extern.slf4j.Slf4j;
@@ -127,6 +129,14 @@ public Map<String, Object> doHttpPut(String url, byte[] data, Map<String, String
127129
throws IOException {
128130
final HttpClientBuilder httpClientBuilder =
129131
HttpClients.custom()
132+
.addInterceptorFirst(
133+
(HttpRequestInterceptor)
134+
(request, context) -> {
135+
// fighting org.apache.http.protocol.RequestContent's
136+
// ProtocolException("Content-Length header already
137+
// present");
138+
request.removeHeaders(HTTP.CONTENT_LEN);
139+
})
130140
.setRedirectStrategy(
131141
new DefaultRedirectStrategy() {
132142
@Override

0 commit comments

Comments
 (0)