Class Guzzle\Http\RedirectPlugin

InheritanceGuzzle\Http\RedirectPlugin
ImplementsSymfony\Component\EventDispatcher\EventSubscriberInterface

Plugin to implement HTTP redirects. Can redirect like a web browser or using strict RFC 2616 compliance

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$defaultMaxRedirects int Default number of redirects allowed when no setting is supplied by a request Guzzle\Http\RedirectPlugin

Public Methods

Hide inherited methods

MethodDescriptionDefined By
cleanupRequest() Clean up the parameters of a request when it is cloned Guzzle\Http\RedirectPlugin
getSubscribedEvents() Guzzle\Http\RedirectPlugin
onRequestSent() Called when a request receives a redirect response Guzzle\Http\RedirectPlugin

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
createRedirectRequest() Create a redirect request for a specific request object Guzzle\Http\RedirectPlugin
getOriginalRequest() Get the original request that initiated a series of redirects Guzzle\Http\RedirectPlugin
prepareRedirection() Prepare the request for redirection and enforce the maximum number of allowed redirects per client Guzzle\Http\RedirectPlugin
sendRedirectRequest() Send a redirect request and handle any errors Guzzle\Http\RedirectPlugin
throwTooManyRedirectsException() Throw a too many redirects exception for a request Guzzle\Http\RedirectPlugin

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
DISABLE 'redirect.disable' Guzzle\Http\RedirectPlugin
MAX_REDIRECTS 'redirect.max' Guzzle\Http\RedirectPlugin
PARENT_REQUEST 'redirect.parent_request' Guzzle\Http\RedirectPlugin
REDIRECT_COUNT 'redirect.count' Guzzle\Http\RedirectPlugin
STRICT_REDIRECTS 'redirect.strict' Guzzle\Http\RedirectPlugin

Property Details

$defaultMaxRedirects protected property

Default number of redirects allowed when no setting is supplied by a request

protected int $defaultMaxRedirects 5

Method Details

cleanupRequest() public method

Clean up the parameters of a request when it is cloned

public void cleanupRequest ( Guzzle\Common\Event $event )
$event Guzzle\Common\Event

Event emitted

createRedirectRequest() protected method

Create a redirect request for a specific request object

Takes into account strict RFC compliant redirection (e.g. redirect POST with POST) vs doing what most clients do (e.g. redirect POST with GET).

protected Guzzle\Http\Message\RequestInterface createRedirectRequest ( Guzzle\Http\Message\RequestInterface $request, $statusCode, $location, Guzzle\Http\Message\RequestInterface $original )
$request Guzzle\Http\Message\RequestInterface

Request being redirected

$statusCode int

Status code of the redirect

$location string

Location header of the redirect

$original Guzzle\Http\Message\RequestInterface

Original request

return Guzzle\Http\Message\RequestInterface

Returns a new redirect request

throws Guzzle\Http\Exception\CouldNotRewindStreamException

If the body needs to be rewound but cannot

getOriginalRequest() protected method

Get the original request that initiated a series of redirects

protected Guzzle\Http\Message\RequestInterface getOriginalRequest ( Guzzle\Http\Message\RequestInterface $request )
$request Guzzle\Http\Message\RequestInterface

Request to get the original request from

getSubscribedEvents() public static method

public static void getSubscribedEvents ( )
onRequestSent() public method

Called when a request receives a redirect response

public void onRequestSent ( Guzzle\Common\Event $event )
$event Guzzle\Common\Event

Event emitted

prepareRedirection() protected method

Prepare the request for redirection and enforce the maximum number of allowed redirects per client

protected Guzzle\Http\Message\RequestInterface prepareRedirection ( Guzzle\Http\Message\RequestInterface $original, Guzzle\Http\Message\RequestInterface $request, Guzzle\Http\Message\Response $response )
$original Guzzle\Http\Message\RequestInterface

Original request

$request Guzzle\Http\Message\RequestInterface

Request to prepare and validate

$response Guzzle\Http\Message\Response

The current response

sendRedirectRequest() protected method

Send a redirect request and handle any errors

protected void sendRedirectRequest ( Guzzle\Http\Message\RequestInterface $original, Guzzle\Http\Message\RequestInterface $request, Guzzle\Http\Message\Response $response )
$original Guzzle\Http\Message\RequestInterface

The originating request

$request Guzzle\Http\Message\RequestInterface

The current request being redirected

$response Guzzle\Http\Message\Response

The response of the current request

throws \Guzzle\Http\Exception\BadResponseException|\Exception
throwTooManyRedirectsException() protected method

Throw a too many redirects exception for a request

protected void throwTooManyRedirectsException ( Guzzle\Http\Message\RequestInterface $original, $max )
$original Guzzle\Http\Message\RequestInterface

Request

$max int

Max allowed redirects

throws Guzzle\Http\Exception\TooManyRedirectsException

when too many redirects have been issued