Previously nsDataChannel would try to avoid unnecessary copies during
nsIURI getters by e.g. cloning the URI without the `ref` component, and
calling methods which were more likely to not require a string copy.
This pattern is no longer optimal after the changes in part 1, and will
instead cause extra string copies. This patch adjusts the code to
reduce back to the original number of copies by reading the full spec
string.
Unfortunately, the `nsIURI` interface does not provide a way to access a
dependent reference to a URI component, so some additional re-parsing of
the URI is required to avoid this copy. This could be optimized further
if such methods were introduced.
As before these changes, the final input stream cannot share the buffer
completely (even if no unescaping or base64-decoding is needed, due to
mime type metadata, etc.). I expect the code to perform the same number
(or fewer) string copies after this change than it did before.
Differential Revision: https://phabricator.services.mozilla.com/D236275