Ejemplo n.º 1
0
 /**
  * Setup the Curl Options.
  *
  * @param  Request $request The Request
  */
 protected function setupCurl(Request $request)
 {
     curl_setopt_array($this->handle, [CURLOPT_URL => $this->fullUrl($request->getUri() . '?' . $request->getQuery(true)), CURLOPT_TIMEOUT => $this->options['timeout'], CURLOPT_CONNECTTIMEOUT => $this->options['connect_timeout'], CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['Content-Type: application/json']]);
     switch ($request->getMethod()) {
         case 'GET':
             curl_setopt($this->handle, CURLOPT_HTTPGET, true);
             curl_setopt($this->handle, CURLOPT_POST, false);
             break;
         case 'POST':
             curl_setopt($this->handle, CURLOPT_HTTPGET, false);
             curl_setopt($this->handle, CURLOPT_POST, true);
             curl_setopt($this->handle, CURLOPT_POSTFIELDS, $request->getBody());
             break;
     }
 }
Ejemplo n.º 2
0
 /**
  * Marshals a Request so it can be dispatched.
  *
  * @param  Request $request The Request to be marshaled.
  */
 public function marshal(Request $request)
 {
     $request->seturi($this->buildPath($request->getUri()));
     $this->signRequest($request);
 }