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 Details

  • Constructor Details

    • HttpByteArrayCacheEntrySerializer

      public HttpByteArrayCacheEntrySerializer()
  • Method Details

    • serialize

      public byte[] serialize(HttpCacheStorageEntry httpCacheEntry) throws ResourceIOException
      Description copied from interface: HttpCacheEntrySerializer
      Serializes the given entry.
      Specified by:
      serialize in interface HttpCacheEntrySerializer<byte[]>
      Parameters:
      httpCacheEntry - cache entry
      Returns:
      serialized representation of the cache entry
      Throws:
      ResourceIOException
    • deserialize

      public HttpCacheStorageEntry deserialize(byte[] serializedObject) throws ResourceIOException
      Description copied from interface: HttpCacheEntrySerializer
      Deserializes a cache entry from its serialized representation.
      Specified by:
      deserialize in interface HttpCacheEntrySerializer<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

      protected InputStream makeByteArrayInputStream(byte[] bytes)
      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