Stream load报错:httpclient头不一致 - Caused by: org.apache.http.ProtocolException: Content-Length header already present at

问题描述:
使用java 封装stream load导入数据抛异常:
Caused by: org.apache.http.ProtocolException: Content-Length header already present at`

httpPut.setConfig(RequestConfig.custom.setRedirectsEnabled(true).build) 是在redirect的时候有问题,重写一下方法即可,例如

private static class ContentLengthHeaderRemover implements HttpRequestInterceptor{
            @Override
            public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
                request.removeHeaders(HTTP.CONTENT_LEN);// fighting org.apache.http.protocol.RequestContent's ProtocolException("Content-Length header already present");
            }
        }
HttpClient client = HttpClients.custom()
                .addInterceptorFirst(new ContentLengthHeaderRemover())
                .build();