Class DeflatingAsyncEntityProducer
- java.lang.Object
-
- org.apache.hc.client5.http.async.methods.DeflatingAsyncEntityProducer
-
- All Implemented Interfaces:
org.apache.hc.core5.http.EntityDetails,org.apache.hc.core5.http.nio.AsyncDataProducer,org.apache.hc.core5.http.nio.AsyncEntityProducer,org.apache.hc.core5.http.nio.ResourceHolder
public final class DeflatingAsyncEntityProducer extends java.lang.Object implements org.apache.hc.core5.http.nio.AsyncEntityProducerAsyncEntityProducerthat streams the output of another producer through the raw DEFLATE compression algorithm.The delegate’s bytes are read in small chunks, compressed with
Deflaterand written immediately to the HTTP I/O layer. Memory use is therefore bounded even for very large request entities.- Since:
- 5.6
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classDeflatingAsyncEntityProducer.InnerChannel
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringcontentTypeprivate java.util.zip.Deflaterdeflaterprivate org.apache.hc.core5.http.nio.AsyncEntityProducerdelegateprivate java.util.concurrent.atomic.AtomicBooleandelegateEndedprivate booleanfinishedprivate byte[]inprivate static intIN_BUFinbound copy‐bufferprivate static intOUT_BUFoutbound staging bufferprivate java.nio.ByteBufferpendingholds compressed bytes not yet sent downstream
-
Constructor Summary
Constructors Constructor Description DeflatingAsyncEntityProducer(org.apache.hc.core5.http.nio.AsyncEntityProducer delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()private voiddeflateToPending()voidfailed(java.lang.Exception cause)private booleanflushPending(org.apache.hc.core5.http.nio.DataStreamChannel ch)copy as much as possible frompendingto the wirejava.lang.StringgetContentEncoding()longgetContentLength()java.lang.StringgetContentType()java.util.Set<java.lang.String>getTrailerNames()booleanisChunked()booleanisRepeatable()voidproduce(org.apache.hc.core5.http.nio.DataStreamChannel channel)voidreleaseResources()
-
-
-
Field Detail
-
IN_BUF
private static final int IN_BUF
inbound copy‐buffer- See Also:
- Constant Field Values
-
OUT_BUF
private static final int OUT_BUF
outbound staging buffer- See Also:
- Constant Field Values
-
delegate
private final org.apache.hc.core5.http.nio.AsyncEntityProducer delegate
-
contentType
private final java.lang.String contentType
-
deflater
private final java.util.zip.Deflater deflater
-
pending
private final java.nio.ByteBuffer pending
holds compressed bytes not yet sent downstream
-
in
private final byte[] in
-
delegateEnded
private final java.util.concurrent.atomic.AtomicBoolean delegateEnded
-
finished
private boolean finished
-
-
Method Detail
-
isRepeatable
public boolean isRepeatable()
- Specified by:
isRepeatablein interfaceorg.apache.hc.core5.http.nio.AsyncEntityProducer
-
getContentLength
public long getContentLength()
- Specified by:
getContentLengthin interfaceorg.apache.hc.core5.http.EntityDetails
-
getContentType
public java.lang.String getContentType()
- Specified by:
getContentTypein interfaceorg.apache.hc.core5.http.EntityDetails
-
getContentEncoding
public java.lang.String getContentEncoding()
- Specified by:
getContentEncodingin interfaceorg.apache.hc.core5.http.EntityDetails
-
isChunked
public boolean isChunked()
- Specified by:
isChunkedin interfaceorg.apache.hc.core5.http.EntityDetails
-
getTrailerNames
public java.util.Set<java.lang.String> getTrailerNames()
- Specified by:
getTrailerNamesin interfaceorg.apache.hc.core5.http.EntityDetails
-
available
public int available()
- Specified by:
availablein interfaceorg.apache.hc.core5.http.nio.AsyncDataProducer
-
produce
public void produce(org.apache.hc.core5.http.nio.DataStreamChannel channel) throws java.io.IOException- Specified by:
producein interfaceorg.apache.hc.core5.http.nio.AsyncDataProducer- Throws:
java.io.IOException
-
flushPending
private boolean flushPending(org.apache.hc.core5.http.nio.DataStreamChannel ch) throws java.io.IOExceptioncopy as much as possible frompendingto the wire- Throws:
java.io.IOException
-
deflateToPending
private void deflateToPending()
-
failed
public void failed(java.lang.Exception cause)
- Specified by:
failedin interfaceorg.apache.hc.core5.http.nio.AsyncEntityProducer
-
releaseResources
public void releaseResources()
- Specified by:
releaseResourcesin interfaceorg.apache.hc.core5.http.nio.ResourceHolder
-
-