I have an API that is returning XML with a leading carriage return (ASCII 13), so when I run the Response::xml() method I am getting an exception. Using trim() on the getBody() will fix this so I've been trying to accomplish this using a 'complete' listener on the request. I've tried both intercept() and setBody(), but I'm not having any luck. Any help/links would be greatly appreciated.
The approach I'm currently using:
$request = $this->client->createRequest([...]);
$request->getEmitter()->on('complete', function(CompleteEvent $e)
{
if ($body = $e->getResponse()->getBody())
{
try {
// This is where I am stuck
$e->intercept(trim($body)); // Fail.
} catch(/Exception $e)
{
// etc.
}
}
});