carterkozak commented on pull request #206:
URL: 
https://github.com/apache/httpcomponents-core/pull/206#issuecomment-667203253


   That makes sense, the other practical drawback to the outputstream-factory 
method is that it becomes more difficult to pass data available from the 
connection implementation into the stream in the future.
   
   Thank you for providing an example. I find it difficult to understand how 
the interface works without reading the code that calls it, which makes me 
think we can implement the API in a cleaner way.
   
   What do you think about exposing a single method along these lines? I can 
write the full example if that makes things easier.
   ```java
      static class OutOfOrderResponseStrategy {
           // Called prior to every write operation.
           void checkForEarlyResponse(final HttpClientConnection conn, final 
InputStream inputStream, final long totalBytesSent, final long nextWriteSize) 
throws IOException {
               if (totalBytesSent == 0 || totalBytesSent / (8 * 1024) < 
((totalBytesSent + nextWriteSize) / (8 * 1024))) {
                   final boolean ssl = conn.getSSLSession() != null;
                   if (ssl ? conn.isDataAvailable(Timeout.ONE_MILLISECOND) : 
(inputStream.available() > 0)) {
                       throw new ResponseOutOfOrderException();
                   }
               }
           }
       }
   ```


----------------------------------------------------------------
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