[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-2407?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18047056#comment-18047056
 ] 

Nicolas Melo commented on HTTPCLIENT-2407:
------------------------------------------

Hi [~olegk] 

Thanks a lot for the explanation.

Yes indeed this is not good news as the API limits requests to 'PUT' method 
with 'Expect/100-continue' header only.

I think the best alternative is to keep using HttpClient 4.x.

I have also tested Java HTTP Client from JDK21 and I have the same issue with 
data transmitted while receiving a redirection. One main difference with 
HttpComponents is that Java HTTP Client removes Authorization header in the 
redirection, so I had to manage redirection manually.

And finally I have tested OKHttp (5.3.2) and it behaves like Http Client 4.x, 
no data transmitted after receiving a redirection. I have to handle redirection 
manually like Java HTTP Client because Authorization header is removed too.

I will benchmark HttpClient 4.x. and OkHttp to decide which solution is the 
best.

 

 

> Unable to send string entity with more than 100000 bytes
> --------------------------------------------------------
>
>                 Key: HTTPCLIENT-2407
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2407
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (classic)
>    Affects Versions: 5.5.1
>            Reporter: Nicolas Melo
>            Priority: Major
>         Attachments: image-2025-12-19-17-21-47-782.png, 
> image-2025-12-19-17-22-00-608.png, log-http5.txt
>
>
> I was using httpclient4 (4.5.14) to send a String entity to Starrocks 
> following example here:  
> [https://github.com/StarRocks/demo/blob/master/MiscDemo/stream_load/java/StarRocksStreamLoad.java#L128]
> I have tried to upgrade to httpclient5 but it fails when String entity is 
> larger than 100000 bytes.
> I don't understand where this limit comes from. It is not an issue on server 
> side as it is working perfectly well with http4 lib.
> Here is the stack trace:
> {code:java}
> java.net.SocketException: Broken pipe
>     at java.base/sun.nio.ch.SocketDispatcher.write0(Native Method)
>     at java.base/sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:62)
>     at java.base/sun.nio.ch.NioSocketImpl.tryWrite(NioSocketImpl.java:394)
>     at java.base/sun.nio.ch.NioSocketImpl.implWrite(NioSocketImpl.java:413)
>     at java.base/sun.nio.ch.NioSocketImpl.write(NioSocketImpl.java:440)
>     at java.base/sun.nio.ch.NioSocketImpl$2.write(NioSocketImpl.java:819)
>     at java.base/java.net.Socket$SocketOutputStream.write(Socket.java:1195)
>     at 
> org.apache.hc.client5.http.impl.io.LoggingOutputStream.write(LoggingOutputStream.java:72)
>     at 
> org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection$1.write(DefaultBHttpClientConnection.java:259)
>     at 
> org.apache.hc.core5.http.impl.io.SessionOutputBufferImpl.write(SessionOutputBufferImpl.java:143)
>     at 
> org.apache.hc.core5.http.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:112)
>     at 
> org.apache.hc.core5.http.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:119)
>     at 
> org.apache.hc.core5.http.io.entity.StringEntity.writeTo(StringEntity.java:188)
>     at 
> org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection.sendRequestEntity(DefaultBHttpClientConnection.java:285)
>     at 
> org.apache.hc.core5.http.impl.io.HttpRequestExecutor.execute(HttpRequestExecutor.java:188)
>     at 
> org.apache.hc.client5.http.impl.classic.InternalExecRuntime.lambda$execute$0(InternalExecRuntime.java:236)
>     at 
> org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager$InternalConnectionEndpoint.execute(PoolingHttpClientConnectionManager.java:798)
>     at 
> org.apache.hc.client5.http.impl.classic.InternalExecRuntime.execute(InternalExecRuntime.java:233)
>     at 
> org.apache.hc.client5.http.impl.classic.MainClientExec.execute(MainClientExec.java:120)
>     at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
>     at 
> org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:200)
>     at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
>     at 
> org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:195)
>     at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
>     at 
> org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:151)
>     at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
>     at 
> org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:112)
>     at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
>     at 
> org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:110)
>     at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
>     at 
> org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:185)
>     at 
> org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:245)
>     at 
> org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:188)
>  {code}
> Thanks for your help!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to