parseHttpResponse method

  1. @visibleForTesting
({Uint8List body, Map<String, String> headers, int statusCode}) parseHttpResponse(
  1. Uint8List bytes
)

Exposed for unit testing — parses a raw HTTP/1.0 response byte buffer.

Returns a record containing the parsed HTTP status code, the lowercased response headers, and the decoded body bytes (chunked encoding is transparently decoded when the transfer-encoding: chunked header is present).

Returns (statusCode: 500, headers: {}, body: <original bytes>) when the response is malformed (i.e., no \r\n\r\n header/body delimiter is found).

Implementation

@visibleForTesting
({int statusCode, Map<String, String> headers, Uint8List body})
    parseHttpResponse(Uint8List bytes) {
  final resp = _parseHttpResponse(bytes);
  return (
    statusCode: resp.statusCode,
    headers: resp.headers,
    body: resp.body
  );
}