You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2021/07/15 15:50:24 UTC
[GitHub] [commons-vfs] garydgregory commented on a change in pull request #186: VFS-805 - HTTP seek always exhausts response
garydgregory commented on a change in pull request #186:
URL: https://github.com/apache/commons-vfs/pull/186#discussion_r670587749
##########
File path: commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/MonitoredHttpResponseContentInputStream.java
##########
@@ -38,8 +41,25 @@ public MonitoredHttpResponseContentInputStream(final ClassicHttpResponse httpRes
this.httpResponse = httpResponse;
}
+ /**
+ * Prevent closing the stream itself if the httpResponse is closeable.
+ * Closing the stream may consume all remaining data no matter how large (VFS-805).
+ */
+ @Override
+ protected void closeSuper() throws IOException {
+ // Suppressed close() invocation on the underlying input stream
+ }
+
@Override
protected void onClose() throws IOException {
+ // Replace the response's entity with a dummy entity in order to prevent
+ // exhausting all data (VFS-805)
+ // Note: HC 5.1 introduces a dedicated NullEntity class
Review comment:
@Aklakan
Our HC 5 code base is now on HC 5.1
##########
File path: commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/MonitoredHttpResponseContentInputStream.java
##########
@@ -38,8 +41,25 @@ public MonitoredHttpResponseContentInputStream(final ClassicHttpResponse httpRes
this.httpResponse = httpResponse;
}
+ /**
+ * Prevent closing the stream itself if the httpResponse is closeable.
+ * Closing the stream may consume all remaining data no matter how large (VFS-805).
+ */
+ @Override
+ protected void closeSuper() throws IOException {
+ // Suppressed close() invocation on the underlying input stream
+ }
+
@Override
protected void onClose() throws IOException {
+ // Replace the response's entity with a dummy entity in order to prevent
+ // exhausting all data (VFS-805)
+ // Note: HC 5.1 introduces a dedicated NullEntity class
+ HttpEntity nullEntity = new ByteArrayEntity(new byte[0], ContentType.APPLICATION_OCTET_STREAM);
+
Review comment:
No need for extra blank lines.
##########
File path: commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/MonitoredHttpResponseContentInputStream.java
##########
@@ -38,8 +41,25 @@ public MonitoredHttpResponseContentInputStream(final ClassicHttpResponse httpRes
this.httpResponse = httpResponse;
}
+ /**
+ * Prevent closing the stream itself if the httpResponse is closeable.
+ * Closing the stream may consume all remaining data no matter how large (VFS-805).
+ */
+ @Override
+ protected void closeSuper() throws IOException {
+ // Suppressed close() invocation on the underlying input stream
+ }
+
@Override
protected void onClose() throws IOException {
+ // Replace the response's entity with a dummy entity in order to prevent
+ // exhausting all data (VFS-805)
+ // Note: HC 5.1 introduces a dedicated NullEntity class
+ HttpEntity nullEntity = new ByteArrayEntity(new byte[0], ContentType.APPLICATION_OCTET_STREAM);
+
+ httpResponse.setEntity(nullEntity);
Review comment:
```
httpResponse.setEntity(NullEntity.INSTANCE);
```
--
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.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org