\Guzzle\HttpRedirectPlugin

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

Summary

Methods
Properties
Constants
getSubscribedEvents()
cleanupRequest()
onRequestSent()
No public properties found
REDIRECT_COUNT
MAX_REDIRECTS
STRICT_REDIRECTS
PARENT_REQUEST
DISABLE
getOriginalRequest()
createRedirectRequest()
prepareRedirection()
sendRedirectRequest()
throwTooManyRedirectsException()
$defaultMaxRedirects
N/A
No private methods found
No private properties found
N/A

Constants

REDIRECT_COUNT

REDIRECT_COUNT = 'redirect.count'

MAX_REDIRECTS

MAX_REDIRECTS = 'redirect.max'

STRICT_REDIRECTS

STRICT_REDIRECTS = 'redirect.strict'

PARENT_REQUEST

PARENT_REQUEST = 'redirect.parent_request'

DISABLE

DISABLE = 'redirect.disable'

Properties

$defaultMaxRedirects

$defaultMaxRedirects : integer

Type

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

Methods

getSubscribedEvents()

getSubscribedEvents() : array

Returns an array of event names this subscriber wants to listen to.

The array keys are event names and the value can be:

  • The method name to call (priority defaults to 0)
  • An array composed of the method name to call and the priority
  • An array of arrays composed of the method names to call and respective priorities, or 0 if unset

For instance:

  • array('eventName' => 'methodName')
  • array('eventName' => array('methodName', $priority))
  • array('eventName' => array(array('methodName1', $priority), array('methodName2')))

Returns

array —

The event names to listen to

cleanupRequest()

cleanupRequest(\Guzzle\Common\Event  $event) 

Clean up the parameters of a request when it is cloned

Parameters

\Guzzle\Common\Event $event

Event emitted

onRequestSent()

onRequestSent(\Guzzle\Common\Event  $event) 

Called when a request receives a redirect response

Parameters

\Guzzle\Common\Event $event

Event emitted

createRedirectRequest()

createRedirectRequest(\Guzzle\Http\Message\RequestInterface  $request, integer  $statusCode, string  $location, \Guzzle\Http\Message\RequestInterface  $original) : \Guzzle\Http\Message\RequestInterface

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).

Parameters

\Guzzle\Http\Message\RequestInterface $request

Request being redirected

integer $statusCode

Status code of the redirect

string $location

Location header of the redirect

\Guzzle\Http\Message\RequestInterface $original

Original request

Throws

\Guzzle\Http\Exception\CouldNotRewindStreamException

If the body needs to be rewound but cannot

Returns

\Guzzle\Http\Message\RequestInterface

Returns a new redirect request

prepareRedirection()

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

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

Parameters

\Guzzle\Http\Message\RequestInterface $original

Original request

\Guzzle\Http\Message\RequestInterface $request

Request to prepare and validate

\Guzzle\Http\Message\Response $response

The current response

Returns

\Guzzle\Http\Message\RequestInterface

sendRedirectRequest()

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

Send a redirect request and handle any errors

Parameters

\Guzzle\Http\Message\RequestInterface $original

The originating request

\Guzzle\Http\Message\RequestInterface $request

The current request being redirected

\Guzzle\Http\Message\Response $response

The response of the current request

Throws

\Guzzle\Http\Exception\BadResponseException|\Exception

throwTooManyRedirectsException()

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

Throw a too many redirects exception for a request

Parameters

\Guzzle\Http\Message\RequestInterface $original

Request

integer $max

Max allowed redirects

Throws

\Guzzle\Http\Exception\TooManyRedirectsException

when too many redirects have been issued