Exemplo n.º 1
0
 protected function clientCall($path, $method = 'GET', $data = array())
 {
     if ($this->request instanceof RequestInterface) {
         $this->request = $this->client->createRequest($method);
     }
     $this->request->setPath($path);
     $this->request->setMethod($method);
     $this->request->setQuery($data);
     if (isset($this->accessToken)) {
         $this->request->getQuery()->set('access_token', $this->accessToken);
     }
     $response = $this->client->send($this->request);
     return $response->json();
 }
Exemplo n.º 2
0
 private function modifyRedirectRequest(RequestInterface $request, ResponseInterface $response)
 {
     $config = $request->getConfig();
     // Use a GET request if this is an entity enclosing request and we are
     // not forcing RFC compliance, but rather emulating what all browsers
     // would do.
     $statusCode = $response->getStatusCode();
     if ($statusCode == 303 || $statusCode <= 302 && $request->getBody() && !$config->getPath('redirect/strict')) {
         $request->setMethod('GET');
         $request->setBody(null);
     }
     $previousUrl = $request->getUrl();
     $this->setRedirectUrl($request, $response);
     $this->rewindEntityBody($request);
     // Add the Referer header if it is told to do so and only
     // add the header if we are not redirecting from https to http.
     if ($config->getPath('redirect/referer') && ($request->getScheme() == 'https' || $request->getScheme() == $config['redirect_scheme'])) {
         $url = Url::fromString($previousUrl);
         $url->setUsername(null);
         $url->setPassword(null);
         $request->setHeader('Referer', (string) $url);
     } else {
         $request->removeHeader('Referer');
     }
 }
 public function withMethod($method)
 {
     $this->expectedRequest->setMethod($method);
     return $this;
 }