The Vary header may contain invalid header name values. We should just
ignore such values as opposed to propagating them to the caller. Before
this patch, attempts to add a request with such a Vary header for example
would fail, since the internal QueryCache() call when executing the
CachePutAllAction would fail.
The Vary header may include one or more HTTP header field names, so we
need to extract those names here, similar to the way that the
nsHttpChannel::ResponseWouldVary() function consumes the Vary header.
InternalHeaders::Get() may throw NS_ERROR_TYPE_ERR with an associated message.
The semantics of ErrorResult dictate that the message needs to be consumed by
the time that the object gets destroyed, so we need to clear it before
returning in these two places.
Before this patch, we would only set these pragmas as part of CreateSchema
which runs in SetupAction. This meant that the connection used to perform
other DBActions would not have had these pragmas applied. As a result,
sqlite would not honor foreign keys on such connections, so the cascade
delete rules responsible for deleting rows from request_headers and
response_headers would not get executed when DBSchema::CachePut deleted the
old entry before adding a new one.
The test in the patch demonstrates how this could result in an observable
breakage. Before this patch, the response headers stored in the cache for
the overwritten entry would reflect both `Mirrored: `foo' and `Mirrored: bar'
headers, which means that attempting to get this header on the cached
response would return the first entry, `foo'.