CapturedResponse

A response as a capture adapter reports it through NetworkCaptureSink.completeRequest.

Built with Builder, never constructed directly, so a field added in a later release arrives as one more optional builder call: an adapter written against an earlier release keeps compiling and linking, and reports that field as unknown. Immutable, and deliberately not a data class.

Types

Link copied to clipboard
class Builder(statusCode: Int, durationMs: Long)

Builds a CapturedResponse with statusCode and durationMs. Unless set, it has no headers, no body, no protocol, no final URL, and no prior responses, and is complete and not mocked.

Properties

Link copied to clipboard

The captured body with its truncation flag and byte size, or null when none was captured.

Link copied to clipboard

Milliseconds from the start of the request to this report.

Link copied to clipboard

The URL the response came from, when it isn't the URL the request was begun with: after the client followed a redirect, or after something that runs after the adapter rewrote the URL. null otherwise, and when the adapter can't tell.

Link copied to clipboard

The response headers.

Link copied to clipboard

true for a finished response. false for an in-flight progressive update: an event stream reports one when its headers arrive and on each read, then a complete response at EOF or close.

Link copied to clipboard

Whether a mock rule produced the response instead of the network.

Link copied to clipboard

The id of the mock rule that produced the response, or null when it isn't mocked or the adapter didn't say which rule.

Link copied to clipboard

The responses the client answered with another request before this one, oldest first: the redirects it followed and the authentication challenges it answered. Empty when there were none, or when the adapter can't see them, as platform HttpURLConnection capture can't.

Link copied to clipboard

The protocol the response came over, as the HTTP client names it, e.g. http/1.1, h2, or h3, or null when it isn't known, as for a mocked response.

Link copied to clipboard

The HTTP status code.