URLRequest body clears when modifying unrelated fields

Hello all and happy new year!

I just came across this bug on Linux Foundation:


It’s very strange. Does that report make sense?

Hello again! I just wanted to bring this bug up again (https://bugs.swift.org/browse/SR-6687). We were just bitten by this hard. It essentially means you are not allowed to create copies of request, for then any edit to the request causes the body to be nil out.

It looks like the copy-on-write step for URLRequest misses that property (and maybe others?) — the setValues method here is what replicates a URLRequest into a fresh instance: