Class HttpByteArrayCacheEntrySerializer

java.lang.Object
org.apache.hc.client5.http.impl.cache.HttpByteArrayCacheEntrySerializer
All Implemented Interfaces:
HttpCacheEntrySerializer<byte[]>

@Contract(threading=STATELESS) public class HttpByteArrayCacheEntrySerializer extends Object implements HttpCacheEntrySerializer<byte[]>
This class implements the HttpCacheEntrySerializer interface, which defines the contract for HTTP cache entry serialization and deserialization. It also includes a default buffer size of 8192 bytes, which can be overridden by specifying a different buffer size in the constructor.
Since:
5.4
  • Field Details

  • Constructor Details

    • HttpByteArrayCacheEntrySerializer

      public HttpByteArrayCacheEntrySerializer(int bufferSize)
      Constructs a HttpByteArrayCacheEntrySerializer with the specified buffer size.
      Parameters:
      bufferSize - the buffer size to use for serialization and deserialization.
    • HttpByteArrayCacheEntrySerializer

      public HttpByteArrayCacheEntrySerializer()
      Constructs a new instance of HttpByteArrayCacheEntrySerializer with a default buffer size.
      See Also:
      • DEFAULT_BUFFER_SIZE
  • Method Details

    • serialize

      public byte[] serialize(HttpCacheStorageEntry storageEntry) throws ResourceIOException
      Serializes an HttpCacheStorageEntry object into a byte array using an HTTP-like format.

      The metadata is encoded into HTTP pseudo-headers for storage.

      Specified by:
      serialize in interface HttpCacheEntrySerializer<byte[]>
      Parameters:
      storageEntry - the HttpCacheStorageEntry to serialize.
      Returns:
      the byte array containing the serialized HttpCacheStorageEntry.
      Throws:
      ResourceIOException - if there is an error during serialization.
    • deserialize

      public HttpCacheStorageEntry deserialize(byte[] serializedObject) throws ResourceIOException
      Deserializes a byte array representation of an HTTP cache storage entry into an instance of HttpCacheStorageEntry.
      Specified by:
      deserialize in interface HttpCacheEntrySerializer<byte[]>
      Parameters:
      serializedObject - the byte array representation of the HTTP cache storage entry
      Returns:
      the deserialized HTTP cache storage entry
      Throws:
      ResourceIOException - if an error occurs during deserialization
    • makeByteArrayInputStream

      @Deprecated protected InputStream makeByteArrayInputStream(byte[] bytes)
      Deprecated.
      Do not use.
      Returns:
      null
    • makeHttpResponseParser

      @Deprecated protected org.apache.hc.core5.http.impl.io.AbstractMessageParser<org.apache.hc.core5.http.ClassicHttpResponse> makeHttpResponseParser()
      Deprecated.
      Do not use.
      Returns:
      null
    • makeHttpResponseWriter

      @Deprecated protected org.apache.hc.core5.http.impl.io.AbstractMessageWriter<SimpleHttpResponse> makeHttpResponseWriter(org.apache.hc.core5.http.io.SessionOutputBuffer outputBuffer)
      Deprecated.
      Do not use.
      Returns:
      null