Ejemplo n.º 1
0
 /**
  * Set the appropriate URL on the request based on the location header
  *
  * @param puzzle_message_RequestInterface  $redirectRequest
  * @param puzzle_message_ResponseInterface $response
  */
 private function setRedirectUrl(puzzle_message_RequestInterface $redirectRequest, puzzle_message_ResponseInterface $response)
 {
     $location = $response->getHeader('Location');
     $location = puzzle_Url::fromString($location);
     // Combine location with the original URL if it is not absolute.
     if (!$location->isAbsolute()) {
         $originalUrl = puzzle_Url::fromString($redirectRequest->getUrl());
         // Remove query string parameters and just take what is present on
         // the redirect Location header
         $originalUrl->getQuery()->clear();
         $location = $originalUrl->combine($location);
     }
     $redirectRequest->setUrl($location);
 }
Ejemplo n.º 2
0
 public function extractCookies(puzzle_message_RequestInterface $request, puzzle_message_ResponseInterface $response)
 {
     if ($cookieHeader = $response->getHeader('Set-Cookie', true)) {
         foreach ($cookieHeader as $cookie) {
             $sc = puzzle_cookie_SetCookie::fromString($cookie);
             if (!$sc->getDomain()) {
                 $sc->setDomain($request->getHost());
             }
             $this->setCookie($sc);
         }
     }
 }