toMockResponse
Writes this fixture as a mockwebserver3.MockResponse that cannot hang or corrupt the exchange. The status line is HTTP/1.1 <status> <reason> with the fixture codec's reason phrase (none for an uncommon status); every header is written as given, in order, except Content-Length and Transfer-Encoding, which the framing decides: a 204 or 205 gets no body and no Content-Length; a 304, or any response to a HEAD, gets no body and keeps the declared length (for HEAD, the body size when none was declared); a fixture carrying Transfer-Encoding is framed as chunked; every other fixture gets its body and Content-Length from the bytes. Content-Length is written after the other headers. A fixture carrying Content-Encoding: gzip must hold encoded bytes: a mismatch fails the exchange fast with an IOException, never hangs.
Stable Core, source compatibility only.
Return
the response, ready to enqueue.
Parameters
the request method the response answers; GET by default. Only a response to HEAD is written differently.
Throws
for a 1xx fixture (never the final response of an exchange), or a 204/205 fixture with a body.