You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by GitBox <gi...@apache.org> on 2020/07/31 16:15:52 UTC

[GitHub] [httpcomponents-core] carterkozak edited a comment on pull request #206: HTTPCORE-639: Configurable ResponseOutOfOrderStrategy

carterkozak edited a comment 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)) {
                       // Maybe replace the exception (currently not public API) with a boolean return value. The implementation can use
                       // the result to throw ResponseOutOfOrderException when necessary without expanding the public API.
                       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:
users@infra.apache.org



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