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

Oleg Kalnichevski commented on HTTPCLIENT-2407:
-----------------------------------------------

[~nicolasm35] I have no good news for you. 

Please see `10.1.1. Expect` section of RFC 9110. 

The server can respond out of sequence in response to a request with `Expect: 
continue` with an error status code 4xx or 5xx. In case of a redirect (3xx) 
cannot just drop the connection while the client is still transmitting data. 
The client in its turn cannot stop sending the request if there is a 
`Content-Length` header as long as the server does not respond with an error 
status code.

HttpClient 4.x behaved differently. It always stops transmitting the message if 
it gets a final response to a request with `Expect: continue`, but that 
behavior was considered incorrect and had to be changed in order to conform to 
the newer revisions of the HTTP protocol. 

What you may want to do in order to avoid the problem, is to hit the server 
with a cheap OPTIONS or HEAD prior to PUT.

Oleg

> 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