我使用apache常见的httpclient 4.3.3来发出http 1.0请求.以下是我提出请求的方式
HttpClient client = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(url);
post.setProtocolVersion(new ProtocolVersion("HTTP", 1, 0));
// trying to remove default headers but it doesn't work
post.removeHeaders("User-Agent");
post.removeHeaders("Accept-Encoding");
post.removeHeaders("Connection");
post.setEntity(new ByteArrayEntity(ba) );
HttpResponse response = client.execute(post);
Run Code Online (Sandbox Code Playgroud)
但是,我可以看到有其他标头自动添加到我的服务器请求中
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.3.3 (java 1.5)
Accept-Encoding: gzip,deflate
Run Code Online (Sandbox Code Playgroud)
如何告诉httpclient不要包含任何其他标题?我试图用post.removeHeaders(xxxx)删除那些标题,但它不起作用.你能告诉我怎么样吗?
谢谢,