Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Not A Problem
-
4.5.2, 4.5.3, 4.5.4, 4.5.5, 4.5.6, 4.5.7, 4.5.8, 4.5.9, 4.5.10, 4.5.11, 4.5.12, 4.5.13
-
None
-
server = Apache Server
Description
I have some trouble, uploading a file with the MultipartEntityBuilder using the Apache HTTP client 4.5.13.
It crashes with an "Software caused connection abort: socket write error" message.
This kind of behavior did not occur in older versions, so I traced it back back to the rather ancient version 4.5.2.
4.5.2 -> aborts with an socket write error
4.5.1 -> works fine
It could be similar to this issue https://issues.apache.org/jira/browse/HTTPCLIENT-1722.
This issue is closed and a duplicate of another issue. Unfortunately there no reference to the original issue, which might contain additional information.
This is the source code:
try (CloseableHttpClient client = HttpClients.createDefault()) {
File file = new File("readyForUpload.tar");
HttpPost postRequest = new HttpPost("https://...");
// enable Expect: 100-continue, because the server
RequestConfig requestConfig = RequestConfig.custom().setExpectContinueEnabled(true).build();
HttpEntity entity = MultipartEntityBuilder.create()
.addBinaryBody("UPLOAD_FILENAME", file, ContentType.APPLICATION_OCTET_STREAM, file.getName())
.addTextBody("SOME_TEXT", "lorem ipsum ...")
.build();
postRequest.setConfig(requestConfig);
postRequest.setEntity(entity);
HttpResponse response = client.execute(postRequest);
HttpEntity responseEntity = response.getEntity();
System.out.println(response.getStatusLine());
if (responseEntity != null)
}