MultipartEntityBuilder setMode()不起作用

时间:2014-12-08 20:17:34

标签: apache-httpcomponents

使用apache httpcomponents-client-4.3.6-bin libs。 此代码生成HttpEntity intance,其中两个部分都包含Content-Tranfer-Encoding标头。我无法使用setMode(HttpMultipartMode.BROWSER_COMPATIBLE)或setLaxMode()消除这些标头。有人有什么建议吗?

MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
List<ContentType> contentTypeList = new ArrayList<>();
contentTypeList.add(ContentType.create("application/x-dmas+json"));
contentTypeList.add(ContentType.create("application/exe"));
int idx = 0;
while(paramKeysIt.hasNext()) {
   builder.addBinaryBody(key = paramKeysIt.next(), params.get(key), contentTypeList.get(idx++),      params.get(key).getName());
}       
HttpEntity reqEntity = builder.build(); 

1 个答案:

答案 0 :(得分:0)

很奇怪。通过将我的请求发送到echo服务器,我能够看到Content-Transfer-Encoding标头确实不存在,即使它们在调试器中显示清楚,并且反复出现! 使用NetBeans IDE 8.0