~canonical-sysadmins/wordpress/openstack-objectstorage-k8s

« back to all changes in this revision

Viewing changes to vendor/guzzlehttp/guzzle/src/Event/HeadersEvent.php

  • Committer: Jacek Nykis
  • Date: 2015-02-11 15:35:31 UTC
  • Revision ID: jacek.nykis@canonical.com-20150211153531-hmy6zi0ov2qfkl0b
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
namespace GuzzleHttp\Event;
 
4
 
 
5
use GuzzleHttp\Adapter\TransactionInterface;
 
6
use GuzzleHttp\Message\ResponseInterface;
 
7
 
 
8
/**
 
9
 * Event object emitted after the response headers of a request have been
 
10
 * received.
 
11
 *
 
12
 * You may intercept the exception and inject a response into the event to
 
13
 * rescue the request.
 
14
 */
 
15
class HeadersEvent extends AbstractRequestEvent
 
16
{
 
17
    /**
 
18
     * @param TransactionInterface $transaction Transaction that contains the
 
19
     *     request and response.
 
20
     * @throws \RuntimeException
 
21
     */
 
22
    public function __construct(TransactionInterface $transaction)
 
23
    {
 
24
        parent::__construct($transaction);
 
25
        if (!$transaction->getResponse()) {
 
26
            throw new \RuntimeException('A response must be present');
 
27
        }
 
28
    }
 
29
 
 
30
    /**
 
31
     * Get the response the was received
 
32
     *
 
33
     * @return ResponseInterface
 
34
     */
 
35
    public function getResponse()
 
36
    {
 
37
        return $this->getTransaction()->getResponse();
 
38
    }
 
39
}