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 ([SR-6687] [Linux] Request body clears after modifying unrelated fields · Issue #3749 · apple/swift-corelibs-foundation · GitHub). 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:

https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/NSURLRequest.swift#L141

https://github.com/apple/swift-corelibs-foundation/pull/1413