コード例 #1
0
ファイル: RedirectPlugin.php プロジェクト: unkerror/Budabot
 /**
  * Clone a request while changing the method to GET. Emulates the behavior of
  * {@see Guzzle\Http\Message\Request::clone}, but can change the HTTP method.
  *
  * @param EntityEnclosingRequestInterface $request Request to clone
  *
  * @return RequestInterface Returns a GET request
  */
 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;
 }