Class HttpByteArrayCacheEntrySerializer
java.lang.Object
org.apache.hc.client5.http.impl.cache.HttpByteArrayCacheEntrySerializer
- All Implemented Interfaces:
HttpCacheEntrySerializer<byte[]>
@Experimental
public class HttpByteArrayCacheEntrySerializer
extends Object
implements HttpCacheEntrySerializer<byte[]>
Cache serializer and deserializer that uses an HTTP-like format.
Existing libraries for reading and writing HTTP are used, and metadata is encoded into HTTP
pseudo-headers for storage.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondeserialize(byte[] serializedObject) Deserializes a cache entry from its serialized representation.protected InputStreammakeByteArrayInputStream(byte[] bytes) Helper method to make a new ByteArrayInputStream.protected org.apache.hc.core5.http.impl.io.AbstractMessageParser<org.apache.hc.core5.http.ClassicHttpResponse> Helper method to make a new HTTP Response parser.protected org.apache.hc.core5.http.impl.io.AbstractMessageWriter<SimpleHttpResponse> makeHttpResponseWriter(org.apache.hc.core5.http.io.SessionOutputBuffer outputBuffer) Helper method to make a new HTTP response writer.byte[]serialize(HttpCacheStorageEntry httpCacheEntry) Serializes the given entry.
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
HttpByteArrayCacheEntrySerializer
public HttpByteArrayCacheEntrySerializer()
-
-
Method Details
-
serialize
Description copied from interface:HttpCacheEntrySerializerSerializes the given entry.- Specified by:
serializein interfaceHttpCacheEntrySerializer<byte[]>- Parameters:
httpCacheEntry- cache entry- Returns:
- serialized representation of the cache entry
- Throws:
ResourceIOException
-
deserialize
Description copied from interface:HttpCacheEntrySerializerDeserializes a cache entry from its serialized representation.- Specified by:
deserializein interfaceHttpCacheEntrySerializer<byte[]>- Parameters:
serializedObject- serialized representation of the cache entry- Returns:
- cache entry
- Throws:
ResourceIOException
-
makeHttpResponseWriter
protected org.apache.hc.core5.http.impl.io.AbstractMessageWriter<SimpleHttpResponse> makeHttpResponseWriter(org.apache.hc.core5.http.io.SessionOutputBuffer outputBuffer) Helper method to make a new HTTP response writer.Useful to override for testing.
- Parameters:
outputBuffer- Output buffer to write to- Returns:
- HTTP response writer to write to
-
makeByteArrayInputStream
Helper method to make a new ByteArrayInputStream.Useful to override for testing.
- Parameters:
bytes- Bytes to read from the stream- Returns:
- Stream to read the bytes from
-
makeHttpResponseParser
protected org.apache.hc.core5.http.impl.io.AbstractMessageParser<org.apache.hc.core5.http.ClassicHttpResponse> makeHttpResponseParser()Helper method to make a new HTTP Response parser.Useful to override for testing.
- Returns:
- HTTP response parser
-