net::HttpUtil::AssembleRawHeaders() is an awkward function which aggregates continued header lines, and normalizes line endings. It re-writes the input such that \0 (NUL) is used as the canonical line separator.
In practice today we consume response headers through HttpResponseHeaders using a pattern like:
new net::HttpResponseHeaders(
net::HttpUtil::AssembleRawHeaders(headers.data(), headers.length()));
At a minimum we should internalize this as an intermediate representation managed by HttpResponseHeaders.
Even better would be if we can get rid of the NUL re-write internally and make things more efficient and general.
IIRC, historically this function existed as a bridge layer -- we would get header lines from WinHTTP as \0 separated goop of text and the rest of the stack operated on this. This design constraint is no longer applicable, and HttpResponseHeaders is the interface to use.
Preliminary concerns with this transition are:
* Dependencies on the format for serialization
* If we end up now allowing embedded NULs in headers, that may expose other problems in parsing code that assumed c-strings (i.e. truncation)
Comment 1 by bugdroid1@chromium.org
, Dec 9 2016