Package lumis.portal.httpintegration
Class BufferedHttpEntity
- java.lang.Object
-
- org.apache.hc.core5.http.io.entity.HttpEntityWrapper
-
- lumis.portal.httpintegration.BufferedHttpEntity
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,org.apache.hc.core5.http.EntityDetails
,org.apache.hc.core5.http.HttpEntity
public class BufferedHttpEntity extends org.apache.hc.core5.http.io.entity.HttpEntityWrapper
NOTE: This is a copy of org.apache.hc.core5.http.io.entity.BufferedHttpEntity that uses the modified writeTo that can abort the connection instead of entity.writeTo that forcefully reads the connection InputStream to the end and prevented the thread from being interrupted. A wrapping entity that buffers it content if necessary. The buffered entity is always repeatable. If the wrapped entity is repeatable itself, calls are passed through. If the wrapped entity is not repeatable, the content is read into a buffer once and provided from there as often as required.- Since:
- 17.0.0
-
-
Constructor Summary
Constructors Constructor Description BufferedHttpEntity(org.apache.hc.core5.http.HttpEntity entity, org.apache.hc.core5.http.ClassicHttpResponse classicHttpResponse, java.util.concurrent.atomic.AtomicBoolean requestTimedOut)
Creates a new buffered entity wrapper.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.InputStream
getContent()
long
getContentLength()
boolean
isChunked()
Tells that this entity does not have to be chunked.boolean
isRepeatable()
Tells that this entity is repeatable.boolean
isStreaming()
void
writeTo(java.io.OutputStream outStream)
static void
writeTo(org.apache.hc.core5.http.HttpEntity entity, java.io.OutputStream outStream, org.apache.hc.core5.http.ClassicHttpResponse classicHttpResponse, java.util.concurrent.atomic.AtomicBoolean requestTimedOut)
Writes the entity content out to the output stream while checking if a hard timeout has occured.
-
-
-
Constructor Detail
-
BufferedHttpEntity
public BufferedHttpEntity(org.apache.hc.core5.http.HttpEntity entity, org.apache.hc.core5.http.ClassicHttpResponse classicHttpResponse, java.util.concurrent.atomic.AtomicBoolean requestTimedOut) throws java.io.IOException, java.lang.InterruptedException
Creates a new buffered entity wrapper.- Parameters:
entity
- the entity to wrap, not nullclassicHttpResponse
- the response to abort, not nullrequestTimedOut
- atomic boolean that identifies if a hard timeout has occured and the request should be canceled- Throws:
java.lang.IllegalArgumentException
- if wrapped is nulljava.io.IOException
- if an I/O error occurs or the request is interrupted and connection abortedjava.lang.InterruptedException
-
-
Method Detail
-
writeTo
public static void writeTo(org.apache.hc.core5.http.HttpEntity entity, java.io.OutputStream outStream, org.apache.hc.core5.http.ClassicHttpResponse classicHttpResponse, java.util.concurrent.atomic.AtomicBoolean requestTimedOut) throws java.io.IOException
Writes the entity content out to the output stream while checking if a hard timeout has occured. In case of a hard timeout, the response connection is aborted before any transfer can be finalized.- Parameters:
entity
- the entityoutStream
- target output stream to write the entity toclassicHttpResponse
- the response that will be aborted in case of a hard timeoutrequestTimedOut
- atomic boolean that identifies if a hard timeout has occured and the request should be canceled- Throws:
java.io.IOException
- if an I/O error occurs or the request is interrupted and connection aborted
-
getContentLength
public long getContentLength()
- Specified by:
getContentLength
in interfaceorg.apache.hc.core5.http.EntityDetails
- Overrides:
getContentLength
in classorg.apache.hc.core5.http.io.entity.HttpEntityWrapper
-
getContent
public java.io.InputStream getContent() throws java.io.IOException
- Specified by:
getContent
in interfaceorg.apache.hc.core5.http.HttpEntity
- Overrides:
getContent
in classorg.apache.hc.core5.http.io.entity.HttpEntityWrapper
- Throws:
java.io.IOException
-
isChunked
public boolean isChunked()
Tells that this entity does not have to be chunked.- Specified by:
isChunked
in interfaceorg.apache.hc.core5.http.EntityDetails
- Overrides:
isChunked
in classorg.apache.hc.core5.http.io.entity.HttpEntityWrapper
- Returns:
false
-
isRepeatable
public boolean isRepeatable()
Tells that this entity is repeatable.- Specified by:
isRepeatable
in interfaceorg.apache.hc.core5.http.HttpEntity
- Overrides:
isRepeatable
in classorg.apache.hc.core5.http.io.entity.HttpEntityWrapper
- Returns:
true
-
writeTo
public void writeTo(java.io.OutputStream outStream) throws java.io.IOException
- Specified by:
writeTo
in interfaceorg.apache.hc.core5.http.HttpEntity
- Overrides:
writeTo
in classorg.apache.hc.core5.http.io.entity.HttpEntityWrapper
- Throws:
java.io.IOException
-
isStreaming
public boolean isStreaming()
- Specified by:
isStreaming
in interfaceorg.apache.hc.core5.http.HttpEntity
- Overrides:
isStreaming
in classorg.apache.hc.core5.http.io.entity.HttpEntityWrapper
-
-