protected function RedirectPlugin::cloneRequestWithGetMethod

Clone a request while changing the method to GET. Emulates the behavior of {

Parameters

EntityEnclosingRequestInterface $request Request to clone:

Return value

RequestInterface Returns a GET request

See also

Guzzle\Http\Message\Request::clone}, but can change the HTTP method.

1 call to RedirectPlugin::cloneRequestWithGetMethod()
RedirectPlugin::createRedirectRequest in drupal/core/vendor/guzzle/http/Guzzle/Http/RedirectPlugin.php
Create a redirect request for a specific request object

File

drupal/core/vendor/guzzle/http/Guzzle/Http/RedirectPlugin.php, line 151

Class

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

Namespace

Guzzle\Http

Code

protected function cloneRequestWithGetMethod(EntityEnclosingRequestInterface $request) {

  // Create a new GET request using the original request's URL
  $redirectRequest = $request
    ->getClient()
    ->get($request
    ->getUrl());
  $redirectRequest
    ->getCurlOptions()
    ->replace($request
    ->getCurlOptions()
    ->getAll());

  // Copy over the headers, while ensuring that the Content-Length is not copied
  $redirectRequest
    ->setHeaders($request
    ->getHeaders()
    ->getAll())
    ->removeHeader('Content-Length');
  $redirectRequest
    ->setEventDispatcher(clone $request
    ->getEventDispatcher());
  $redirectRequest
    ->getParams()
    ->replace($request
    ->getParams()
    ->getAll())
    ->remove('curl_handle')
    ->remove('queued_response')
    ->remove('curl_multi');
  return $redirectRequest;
}