michael-o commented on a change in pull request #206:
URL: 
https://github.com/apache/httpcomponents-core/pull/206#discussion_r464103081



##########
File path: 
httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java
##########
@@ -157,41 +198,40 @@ public void sendRequestEntity(final ClassicHttpRequest 
request) throws HttpExcep
         try (final OutputStream outStream = createContentOutputStream(
                 len, this.outbuffer, new OutputStream() {
 
-                    final boolean ssl = socketHolder.getSocket() instanceof 
SSLSocket;
-                    final InputStream socketInputStream = 
socketHolder.getInputStream();
                     final OutputStream socketOutputStream = 
socketHolder.getOutputStream();
+                    final InputStream socketInputStream = 
socketHolder.getInputStream();
 
                     long totalBytes = 0;
-                    long chunks = -1;
 
-                    void checkForEarlyResponse() throws IOException {
-                        final long n = totalBytes / (8 * 1024);
-                        if (n > chunks) {
-                            chunks = n;
-                            if (ssl ? isDataAvailable(Timeout.ONE_MILLISECOND) 
: (socketInputStream.available() > 0)) {
-                                throw new ResponseOutOfOrderException();
-                            }
+                    void checkForEarlyResponse(final long totalBytesSent, 
final int nextWriteSize) throws IOException {
+                        if (responseOutOfOrderStrategy.checkForEarlyResponse(
+                                DefaultBHttpClientConnection.this,
+                                request,
+                                socketInputStream,
+                                totalBytesSent,
+                                nextWriteSize)) {
+                            throw new ResponseOutOfOrderException();
                         }
                     }
 
                     @Override
                     public void write(final byte[] b) throws IOException {
+                        checkForEarlyResponse(totalBytes, b.length);

Review comment:
       Accepted.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to