How can I disable default request headers from apache httpclient 4?

前端 未结 4 1630
终归单人心
终归单人心 2020-12-14 21:55

I am using apache common httpclient 4.3.3 to make http 1.0 request. Here is how I make the request

HttpClient client = HttpClientBuilder.create().build();
Ht         


        
4条回答
  •  一生所求
    2020-12-14 22:22

    I think you could add your implementation of HttpRequestInterceptor with client.addRequestInterceptor()
    or (better)
    remove all interceptors that add headers to the request (RequestUserAgent, RequestDefaultHeaders, RequestClientConnControl, RequestAcceptEncoding, ...).

    Removing them is also easy:

    client.removeRequestInterceptorByClass(RequestAcceptEncoding.class);
    

提交回复
热议问题