This is needed for use cases like T183722, when a WebRequest instance is being created programmatically, and we would like to assign an arbitrary IP and UA to it. Currently, IP can be set using setIP(). User-agent strings are stored in a header called User-Agent and CheckUser retrieves this using $wgRequest->getHeader( 'User-Agent' ); such as in CheckUserhooks.php but it is not possible to override the value of a request header. Therefore, this task will add a setHeader() function to override a header whenever applicable.
@kaldari LoginNotify doesn't use it *now* but will be using it once we connect it to CheckUser, which is the plan.
To be able to test the code that we/I will be writing for the integration of LN and CU, we need a way to generate WebRequests with arbitrarily assigned UAs and IPs. Hence the current task and associated patch.