from

fun from(response: Response): ResponseCache?

Creates a ResponseCache from response if it is eligible for caching.

The response body is consumed (buffered) by this call. If you also need the body for other purposes, buffer it first and use the from overload that accepts a pre-buffered ByteString.

Return

The ResponseCache; null if the response is not eligible for caching.

Parameters

response

The HTTP response whose body will be consumed and cached.


fun from(response: Response, bodyByteString: ByteString, contentType: MediaType?): ResponseCache?

Creates a ResponseCache from response using a pre-buffered body if the response is eligible for caching.

Use this overload when the body has already been read and must remain available for other consumers after this call returns.

Return

The ResponseCache; null if the response is not eligible for caching.

Parameters

response

The HTTP response whose headers and status code determine eligibility.

bodyByteString

The already-buffered response body bytes.

contentType

The media type of the body, used when reconstructing the ResponseBody.