Class RedirectPlugin
Plugin to implement HTTP redirects. Can redirect like a web browser or using strict RFC 2616 compliance
- Guzzle\Http\RedirectPlugin implements Symfony\Component\EventDispatcher\EventSubscriberInterface
Methods summary
-
public static
getSubscribedEvents ( )
-
public
cleanupRequest ( Guzzle\Common\Event $event )
Clean up the parameters of a request when it is cloned
-
public
onRequestSent ( Guzzle\Common\Event $event )
Called when a request receives a redirect response
-
protected
getOriginalRequest ( Guzzle\Http\Message\RequestInterface $request )
Get the original request that initiated a series of redirects
-
protected
createRedirectRequest ( Guzzle\Http\Message\RequestInterface $request, RequestInterface $statusCode, int $location, Guzzle\Http\Message\RequestInterface $original )
Create a redirect request for a specific request object
-
protected
prepareRedirection ( Guzzle\Http\Message\RequestInterface $original, Guzzle\Http\Message\RequestInterface $request, Guzzle\Http\Message\Response $response )
Prepare the request for redirection and enforce the maximum number of allowed redirects per client
-
protected
sendRedirectRequest ( Guzzle\Http\Message\RequestInterface $original, Guzzle\Http\Message\RequestInterface $request, Guzzle\Http\Message\Response $response )
Send a redirect request and handle any errors
-
protected
throwTooManyRedirectsException ( Guzzle\Http\Message\RequestInterface $original, int $max )
Throw a too many redirects exception for a request
Methods detail
Clean up the parameters of a request when it is cloned
Parameters
- $event
Guzzle\Common\Event
$event Event emitted
Called when a request receives a redirect response
Parameters
- $event
Guzzle\Common\Event
$event Event emitted
protected
Guzzle\Http\Message\RequestInterface
getOriginalRequest( Guzzle\Http\Message\RequestInterface
$request )
Get the original request that initiated a series of redirects
Parameters
- $request
Guzzle\Http\Message\RequestInterface
$request Request to get the original request from
Returns
protected
Guzzle\Http\Message\RequestInterface
createRedirectRequest( Guzzle\Http\Message\RequestInterface
$request, Guzzle\Http\Message\RequestInterface
$statusCode, integer $location, Guzzle\Http\Message\RequestInterface
$original )
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
- $request
Guzzle\Http\Message\RequestInterface
$request Request being redirected- $statusCode
Guzzle\Http\Message\RequestInterface
$original Original request- $location
integer
$statusCode Status code of the redirect- $original
string
$location Location header of the redirect
Returns
Throws
protected
Guzzle\Http\Message\RequestInterface
prepareRedirection( Guzzle\Http\Message\RequestInterface
$original, Guzzle\Http\Message\RequestInterface
$request, Guzzle\Http\Message\Response
$response )
Prepare the request for redirection and enforce the maximum number of allowed redirects per client
Parameters
- $original
Guzzle\Http\Message\RequestInterface
$original Original request- $request
Guzzle\Http\Message\RequestInterface
$request Request to prepare and validate- $response
Guzzle\Http\Message\Response
$response The current response
Returns
protected
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
- $original
Guzzle\Http\Message\RequestInterface
$original The originating request- $request
Guzzle\Http\Message\RequestInterface
$request The current request being redirected- $response
Guzzle\Http\Message\Response
$response The response of the current request
Throws
protected
throwTooManyRedirectsException( Guzzle\Http\Message\RequestInterface
$original, integer $max )
Throw a too many redirects exception for a request
Parameters
- $original
Guzzle\Http\Message\RequestInterface
$original Request- $max
integer
$max Max allowed redirects
Throws
Magic methods summary
Constants summary
string |
REDIRECT_COUNT |
'redirect.count' |
|
string |
MAX_REDIRECTS |
'redirect.max' |
|
string |
STRICT_REDIRECTS |
'redirect.strict' |
|
string |
PARENT_REQUEST |
'redirect.parent_request' |
|
string |
DISABLE |
'redirect.disable' |
Properties summary
protected
integer
|
$defaultMaxRedirects |
#
Default number of redirects allowed when no setting is supplied by a request |