multidict icon indicating copy to clipboard operation
multidict copied to clipboard

Implement md.merge(other)

Open asvetlov opened this issue 6 years ago • 3 comments

The method should be mimic to md.extend() but add only keys from other that are absent in self.

The behavior is very useful for merging aiohttp session defaults into passed headers for example.

asvetlov avatar Sep 28 '18 05:09 asvetlov

Why not replace existing keys?

webknjaz avatar Sep 30 '18 14:09 webknjaz

Replacing is another useful strategy already implemented by md.update(). I'm talking about this case:

  1. Aiohttp client session has a set of default HTTP headers.
  2. client.request() accepts headers for the concrete request. Default headers should be merged into passed to request() one but session defaults should not override formers.

asvetlov avatar Sep 30 '18 15:09 asvetlov

Ok, makes sense

webknjaz avatar Sep 30 '18 17:09 webknjaz