[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-2220?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sebastian Braun closed HTTPCLIENT-2220.
---------------------------------------
    Resolution: Not A Problem

The server was the problem, not the Apache HTTP client.

> file upload with MultipartEntityBuilder causes "socket write error"
> -------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-2220
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2220
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (classic)
>    Affects Versions: 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
>         Environment: server = Apache Server
>            Reporter: Sebastian Braun
>            Priority: Major
>             Fix For: 4.5.13
>
>
> I have some trouble, uploading a file with the MultipartEntityBuilder using 
> the Apache HTTP client 4.5.13.
> It crashes with an {color:#de350b}"Software caused connection abort: socket 
> write error"{color} 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) {
>     System.out.println(EntityUtils.toString(responseEntity));
>     EntityUtils.consume(responseEntity);
>   }
> }



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to