withAdditionalHeaders method
Returns a context that shares this one's session state and sends this
context's headers with headers merged in on top.
This is withHeaders for the case every real caller has: adding a header
— an atproto-proxy routing one client's calls to a different service,
say — without discarding the ones the origin context already sends. See
withHeaders for what "shares this one's session state" buys and why a
second context would otherwise race for the single-use refresh token.
headers wins on conflict, and the comparison is case-insensitive
because header names are: a context already sending Atproto-Proxy and
an headers carrying atproto-proxy name one header, not two. Merging
key-exactly would keep both, which package:http happens to collapse but
a custom xrpc.GetClient forwarding the raw map to dart:io or Dio
emits verbatim — two atproto-proxy headers, with the server free to
honour whichever it reads first.
final proxied = ctx.withAdditionalHeaders(const {
'atproto-proxy': 'did:web:example.com#service',
});
Implementation
ServiceContext withAdditionalHeaders(final Map<String, String> headers) =>
withHeaders(_mergeHeaders(_headers ?? const {}, headers));