Exemplo n.º 1
0
Arquivo: Yo.php Projeto: toin0u/yo
 private function send($url, $method = InternalRequestInterface::METHOD_GET, array $data = array())
 {
     try {
         return $this->adapter->send(sprintf('%s/%s', self::ENDPOINT, $url), $method, array(), $data);
     } catch (\Exception $e) {
         throw new \RuntimeException(sprintf('[Yo] something went wrong `%s` the response body was `%s` !', $e->getMessage(), $e->hasResponse() ? $e->getResponse()->getBody()->getContents() : 'not defined'));
     }
 }
 /**
  * @param string $method
  * @param string $uri With or without host
  * @param string|resource|array $body
  */
 private function send($method, $uri, $body = null)
 {
     if (!$this->hasHost($uri)) {
         $uri = rtrim($this->httpClient->getConfiguration()->getBaseUri(), '/') . '/' . ltrim($uri, '/');
     }
     $stream = new Stream('php://memory', 'rw');
     if ($body) {
         $stream->write($body);
     }
     $this->request = new Request($uri, $method, $stream, $this->requestHeaders);
     $this->response = $this->httpClient->send($uri, $method, $this->requestHeaders, $body);
     // Reset headers used for the HTTP request
     $this->requestHeaders = array();
 }