3
namespace GuzzleHttp\Event;
5
use GuzzleHttp\Adapter\TransactionInterface;
6
use GuzzleHttp\Message\ResponseInterface;
9
* Event object emitted after the response headers of a request have been
12
* You may intercept the exception and inject a response into the event to
15
class HeadersEvent extends AbstractRequestEvent
18
* @param TransactionInterface $transaction Transaction that contains the
19
* request and response.
20
* @throws \RuntimeException
22
public function __construct(TransactionInterface $transaction)
24
parent::__construct($transaction);
25
if (!$transaction->getResponse()) {
26
throw new \RuntimeException('A response must be present');
31
* Get the response the was received
33
* @return ResponseInterface
35
public function getResponse()
37
return $this->getTransaction()->getResponse();