Top Inners Fields Constructors Methods
org.apache.hc.client5.http.impl.classic

pack-priv Class ResponseEntityProxy

extends HttpEntityWrapper
implements EofSensorWatcher
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.io.EofSensorWatcher
Imports
java.io.IOException, .InputStream, .OutputStream, java.net.SocketException, java.util.Arrays, .List, org.apache.hc.client5.http.classic.ExecRuntime, org.apache.hc.core5.function.Supplier, org.apache.hc.core5.http.ClassicHttpResponse, .Header, .HttpEntity, org.apache.hc.core5.http.impl.io.ChunkedInputStream, org.apache.hc.core5.http.io.EofSensorInputStream, .EofSensorWatcher, org.apache.hc.core5.http.io.entity.HttpEntityWrapper

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final ExecRuntime

Constructor Summary

AccessConstructor and Description
pack-priv
ResponseEntityProxy(final HttpEntity entity, final ExecRuntime execRuntime)

Method Summary

Modifier and TypeMethod and Description
private void
public void
close()

Overrides org.apache.hc.core5.http.io.entity.HttpEntityWrapper.close.

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.
private void
public static void
enhance(final ClassicHttpResponse response, final ExecRuntime execRuntime)

public boolean
eofDetected(final InputStream
the underlying stream which has reached EOF
wrapped
)

Implements org.apache.hc.core5.http.io.EofSensorWatcher.eofDetected.

Indicates that EOF is detected.
public InputStream
public Supplier<List<? extends Header>>
getTrailers()

Overrides org.apache.hc.core5.http.io.entity.HttpEntityWrapper.getTrailers.

Implements org.apache.hc.core5.http.HttpEntity.getTrailers.

Returns supplier of message trailers - headers sent after message body.
public boolean
isRepeatable()

Overrides org.apache.hc.core5.http.io.entity.HttpEntityWrapper.isRepeatable.

Implements org.apache.hc.core5.http.HttpEntity.isRepeatable.

Tells if the entity is capable of producing its data more than once.
public void
public boolean
streamAbort(final InputStream
the underlying stream which has not reached EOF
wrapped
)

Implements org.apache.hc.core5.http.io.EofSensorWatcher.streamAbort.

Indicates that the stream is aborted.
public boolean
streamClosed(final InputStream
the underlying stream which has not reached EOF
wrapped
)

Implements org.apache.hc.core5.http.io.EofSensorWatcher.streamClosed.

Indicates that the stream is closed.
public void
writeTo(final OutputStream
the output stream to write entity content to
outStream
)

Overrides org.apache.hc.core5.http.io.entity.HttpEntityWrapper.writeTo.

Implements org.apache.hc.core5.http.HttpEntity.writeTo.

Writes the entity content out to the output stream.
Inherited from org.apache.hc.core5.http.io.entity.HttpEntityWrapper:
getContentEncodinggetContentLengthgetContentTypegetTrailerNamesisChunkedisStreamingtoString

Field Detail

execRuntimeback to summary
private final ExecRuntime execRuntime

Constructor Detail

ResponseEntityProxyback to summary
pack-priv ResponseEntityProxy(final HttpEntity entity, final ExecRuntime execRuntime)

Method Detail

cleanupback to summary
private void cleanup() throws IOException
closeback to summary
public void close() throws IOException

Overrides org.apache.hc.core5.http.io.entity.HttpEntityWrapper.close.

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
discardConnectionback to summary
private void discardConnection()
enhanceback to summary
public static void enhance(final ClassicHttpResponse response, final ExecRuntime execRuntime)
eofDetectedback to summary
public boolean eofDetected(final InputStream wrapped) throws IOException

Implements org.apache.hc.core5.http.io.EofSensorWatcher.eofDetected.

Doc from org.apache.hc.core5.http.io.EofSensorWatcher.eofDetected.

Indicates that EOF is detected.

Parameters
wrapped:InputStream

the underlying stream which has reached EOF

Returns:boolean

true if wrapped should be closed, false if it should be left alone

Annotations
@Override
Exceptions
IOException:
in case of an IO problem, for example if the watcher itself closes the underlying stream. The caller will leave the wrapped stream alone, as if false was returned.
getContentback to summary
public InputStream getContent() throws IOException

Overrides org.apache.hc.core5.http.io.entity.HttpEntityWrapper.getContent.

Implements org.apache.hc.core5.http.HttpEntity.getContent.

Doc from org.apache.hc.core5.http.HttpEntity.getContent.

Returns a content stream of the entity. Repeatable entities are expected to create a new instance of InputStream for each invocation of this method and therefore can be consumed multiple times. Entities that are not repeatable are expected to return the same InputStream instance and therefore may not be consumed more than once.

If this entity belongs to an incoming HTTP message, calling InputStream#close() on the returned InputStream will try to consume the complete entity content to keep the connection alive. In cases where this is undesired, e.g. when only a small part of the content is relevant and consuming the complete entity content would be too inefficient, only the HTTP message from which this entity was obtained should be closed (if supported).

Important Note

Please note all entity implementations must ensure that all allocated resources are properly deallocated after the InputStream#close() method is invoked.

Returns:InputStream

content stream of the entity.

Annotations
@Override
Exceptions
IOException:
if the stream could not be created
getTrailersback to summary
public Supplier<List<? extends Header>> getTrailers()

Overrides org.apache.hc.core5.http.io.entity.HttpEntityWrapper.getTrailers.

Implements org.apache.hc.core5.http.HttpEntity.getTrailers.

Doc from org.apache.hc.core5.http.HttpEntity.getTrailers.

Returns supplier of message trailers - headers sent after message body. May return null if trailers are not available.

Annotations
@Override
isRepeatableback to summary
public boolean isRepeatable()

Overrides org.apache.hc.core5.http.io.entity.HttpEntityWrapper.isRepeatable.

Implements org.apache.hc.core5.http.HttpEntity.isRepeatable.

Doc from org.apache.hc.core5.http.HttpEntity.isRepeatable.

Tells if the entity is capable of producing its data more than once. A repeatable entity's getContent() and writeTo(OutputStream) methods can be called more than once whereas a non-repeatable entity's can not.

Returns:boolean

true if the entity is repeatable, false otherwise.

Annotations
@Override
releaseConnectionback to summary
public void releaseConnection()
streamAbortback to summary
public boolean streamAbort(final InputStream wrapped) throws IOException

Implements org.apache.hc.core5.http.io.EofSensorWatcher.streamAbort.

Doc from org.apache.hc.core5.http.io.EofSensorWatcher.streamAbort.

Indicates that the stream is aborted. This method will be called only if EOF was not detected before aborting. Otherwise, eofDetected is called.

This method will also be invoked when an input operation causes an IOException to be thrown to make sure the input stream gets shut down.

Parameters
wrapped:InputStream

the underlying stream which has not reached EOF

Returns:boolean

true if wrapped should be closed, false if it should be left alone

Annotations
@Override
Exceptions
IOException:
in case of an IO problem, for example if the watcher itself closes the underlying stream. The caller will leave the wrapped stream alone, as if false was returned.
streamClosedback to summary
public boolean streamClosed(final InputStream wrapped) throws IOException

Implements org.apache.hc.core5.http.io.EofSensorWatcher.streamClosed.

Doc from org.apache.hc.core5.http.io.EofSensorWatcher.streamClosed.

Indicates that the stream is closed. This method will be called only if EOF was not detected before closing. Otherwise, eofDetected is called.

Parameters
wrapped:InputStream

the underlying stream which has not reached EOF

Returns:boolean

true if wrapped should be closed, false if it should be left alone

Annotations
@Override
Exceptions
IOException:
in case of an IO problem, for example if the watcher itself closes the underlying stream. The caller will leave the wrapped stream alone, as if false was returned.
writeToback to summary
public void writeTo(final OutputStream outStream) throws IOException

Overrides org.apache.hc.core5.http.io.entity.HttpEntityWrapper.writeTo.

Implements org.apache.hc.core5.http.HttpEntity.writeTo.

Doc from org.apache.hc.core5.http.HttpEntity.writeTo.

Writes the entity content out to the output stream.

Important Note

Please note all entity implementations must ensure that all allocated resources are properly deallocated when this method returns.

Parameters
outStream:OutputStream

the output stream to write entity content to

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
org.apache.hc.client5.http.impl.classic back to summary

private final Class ResponseEntityProxy.NullOutputStream

extends OutputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final ResponseEntityProxy.NullOutputStream

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Closes this output stream and releases any system resources associated with this stream.
public void
flush()

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Flushes this output stream and forces any buffered output bytes to be written out.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
write(final int
the byte.
byteValue
)

Implements abstract java.io.OutputStream.write.

Writes the specified byte to this output stream.
public void
write(final byte[]
the data.
buffer
)

Overrides java.io.OutputStream.write.

Writes b.length bytes from the specified byte array to this output stream.
public void
write(final byte[]
the data.
buffer
,
final int
the start offset in the data.
off
,
final int
the number of bytes to write.
len
)

Overrides java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.
Inherited from java.io.OutputStream:
nullOutputStream

Field Detail

INSTANCEback to summary
private static final ResponseEntityProxy.NullOutputStream INSTANCE

Constructor Detail

NullOutputStreamback to summary
private NullOutputStream()

Method Detail

closeback to summary
public void close()

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.OutputStream.close.

Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.

Annotations
@Override
flushback to summary
public void flush()

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Doc from java.io.OutputStream.flush.

Flushes this output stream and forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.

If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
writeback to summary
public void write(final int byteValue)

Implements abstract java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Parameters
byteValue:int

the byte.

Annotations
@Override
writeback to summary
public void write(final byte[] buffer)

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes b.length bytes from the specified byte array to this output stream. The general contract for write(b) is that it should have exactly the same effect as the call write(b, 0, b.length).

Parameters
buffer:byte[]

the data.

Annotations
@Override
writeback to summary
public void write(final byte[] buffer, final int off, final int len)

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation.

If b is null, a NullPointerException is thrown.

If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

Parameters
buffer:byte[]

the data.

off:int

the start offset in the data.

len:int

the number of bytes to write.

Annotations
@Override