Instead of trying to find a way to fake a sealed
object, I'd instead look to see if I can get a real instance of one, assuming it doesn't have too many dependencies.
On the plus side, HttpRequestHeaders
doesn't have too many dependencies. On the down side, it only has an internal
constructor. Happily, though, HttpRequestMessage
can be freely constructed and exposes a Headers
property which will perform the required construction for you.
Alternatively, you might consider using reflection to create the object despite it only having the internal
constructor - it's pick your poison time - create an unneeded, disposable object to cleanly create the headers, or start using reflection.